[ { "hash": "c8bfc6162857f9989dd6c75ebb5af4cd655ce9dc", "msg": "fixed error in get_compiler_dir that was breaking Linux builds.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-20T22:41:50+00:00", "author_timezone": 0, "committer_date": "2002-09-20T22:41:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9ec0eb7714b132ea85db3a88f78c5f368cbd3bdd" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 8, "lines": 9, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -321,7 +321,14 @@ def run_command(command):\n run_command = commands.getstatusoutput\n \n def get_compiler_dir(compiler_name):\n- if compiler_name == 'gcc': \n+ \"\"\" Try to figure out the compiler directory based on the\n+ input compiler name. This is fragile and really should\n+ be done at the distutils level inside the compiler. I\n+ think it is only useful on windows at the moment.\n+ \"\"\"\n+ if compiler_name is None:\n+ compiler_dir = ''\n+ elif compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n", "added_lines": 8, "deleted_lines": 1, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\n\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add gccX.X to the \n # path.\n compiler_dir = get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n if compiler_name is None:\n compiler_dir = ''\n elif compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n version = re.findall('\\d\\.\\d',text)[0]\n except IndexError:\n version = ''\n compiler_dir = compiler_name + version\n else: \n compiler_dir = compiler_name\n return compiler_dir\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\n\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add gccX.X to the \n # path.\n compiler_dir = get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef get_compiler_dir(compiler_name):\n if compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n version = re.findall('\\d\\.\\d',text)[0]\n except IndexError:\n version = ''\n compiler_dir = compiler_name + version\n else: \n compiler_dir = compiler_name\n return compiler_dir\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 32, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 390, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 171, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 226, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 241, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 249, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 272, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 294, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 323, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 343, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 359, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 396, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 450, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 460, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 491, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 495, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 32, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 390, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 171, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 226, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 241, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 249, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 272, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 294, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 323, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 336, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 352, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 389, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 443, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 453, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 488, "end_line": 490, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 323, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "nloc": 257, "complexity": 61, "token_count": 1584, "diff_parsed": { "added": [ " \"\"\" Try to figure out the compiler directory based on the", " input compiler name. This is fragile and really should", " be done at the distutils level inside the compiler. I", " think it is only useful on windows at the moment.", " \"\"\"", " if compiler_name is None:", " compiler_dir = ''", " elif compiler_name == 'gcc':" ], "deleted": [ " if compiler_name == 'gcc':" ] } } ] }, { "hash": "d0074f705a7c0b4aa443df008c41555aece86047", "msg": "Fixed jiffies scaling in ScipyTestCase.measure", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-20T22:48:09+00:00", "author_timezone": 0, "committer_date": "2002-09-20T22:48:09+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c8bfc6162857f9989dd6c75ebb5af4cd655ce9dc" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -67,7 +67,7 @@ def measure(self,code_str,times=1):\n i += 1\n exec code in locs,globs\n elapsed = jiffies() - elapsed\n- return elapsed\n+ return 0.01*elapsed\n \n def remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\ndef get_package_path(testfile):\n \"\"\" Return path to package directory first assuming that testfile\n satisfies the following tree structure:\n /build/lib.-\n //testfile\n If build directory does not exist, then return\n /..\n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return os.path.dirname(d)\n\nif sys.platform=='linux2':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i/build/lib.-\n //testfile\n If build directory does not exist, then return\n /..\n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return os.path.dirname(d)\n\nif sys.platform=='linux2':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i/build/lib.-\n- //testfile\n- If build directory does not exist, then return\n- \n- \"\"\"\n- from distutils.util import get_platform\n- d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n- d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n- if os.path.isdir(d1):\n- return d1\n- return d\n-\n-if sys.platform=='linux2':\n- def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n- _load_time=time.time()):\n- \"\"\" Return number of jiffies (1/100ths of a second) that this\n- process has been scheduled in user mode. See man 5 proc. \"\"\"\n- try:\n- f=open(_proc_pid_stat,'r')\n- l = f.readline().split(' ')\n- f.close()\n- return int(l[13])\n- except:\n- return int(100*(time.time()-_load_time))\n-else:\n- # os.getpid is not in all platforms available.\n- # Using time is safe but inaccurate, especially when process\n- # was suspended or sleeping.\n- def jiffies(_load_time=time.time()):\n- \"\"\" Return number of jiffies (1/100ths of a second) that this\n- process has been scheduled in user mode. See man 5 proc. \"\"\"\n- return int(100*(time.time()-_load_time))\n-\n-__all__.append('ScipyTestCase')\n-class ScipyTestCase (unittest.TestCase):\n-\n- def measure(self,code_str,times=1):\n- \"\"\" Return elapsed time for executing code_str in the\n- namespace of the caller for given times.\n- \"\"\"\n- frame = sys._getframe(1)\n- locs,globs = frame.f_locals,frame.f_globals\n- code = compile(code_str,\n- 'ScipyTestCase runner for '+self.__class__.__name__,\n- 'exec')\n- i = 0\n- elapsed = jiffies()\n- while i/build/lib.-\n //testfile\n If build directory does not exist, then return\n \n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return d\n\nif sys.platform=='linux2':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n return int(100*(time.time()-_load_time))\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i/build/lib.-", " //testfile", " If build directory does not exist, then return", " ", " \"\"\"", " from distutils.util import get_platform", " d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))", " d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))", " if os.path.isdir(d1):", " return d1", " return d", "", "if sys.platform=='linux2':", " def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),", " _load_time=time.time()):", " \"\"\" Return number of jiffies (1/100ths of a second) that this", " process has been scheduled in user mode. See man 5 proc. \"\"\"", " try:", " f=open(_proc_pid_stat,'r')", " l = f.readline().split(' ')", " f.close()", " return int(l[13])", " except:", " return int(100*(time.time()-_load_time))", "else:", " # os.getpid is not in all platforms available.", " # Using time is safe but inaccurate, especially when process", " # was suspended or sleeping.", " def jiffies(_load_time=time.time()):", " \"\"\" Return number of jiffies (1/100ths of a second) that this", " process has been scheduled in user mode. See man 5 proc. \"\"\"", " return int(100*(time.time()-_load_time))", "", "__all__.append('ScipyTestCase')", "class ScipyTestCase (unittest.TestCase):", "", " def measure(self,code_str,times=1):", " \"\"\" Return elapsed time for executing code_str in the", " namespace of the caller for given times.", " \"\"\"", " frame = sys._getframe(1)", " locs,globs = frame.f_locals,frame.f_globals", " code = compile(code_str,", " 'ScipyTestCase runner for '+self.__class__.__name__,", " 'exec')", " i = 0", " elapsed = jiffies()", " while i= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() file in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir'] \n\ndef default_config_dict(name = None, parent_name = None):\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n if name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n d['name'] = full_name\n if not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n", "source_code_before": "import os,sys,string\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not sys.stdout.isatty(): return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() file in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir'] \n\ndef default_config_dict(name = None, parent_name = None):\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n if name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n d['name'] = full_name\n if not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 48, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 156, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 172, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 201, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 231, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 25, "complexity": 10, "token_count": 211, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 311, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 320, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 329, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 336, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 339, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 14, "complexity": 9, "token_count": 106, "parameters": [], "start_line": 5, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 47, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 155, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 171, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 200, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 222, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 227, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 230, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 246, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 258, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 25, "complexity": 10, "token_count": 211, "parameters": [ "name", "parent_name" ], "start_line": 277, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 310, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 319, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 328, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 335, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 } ], "nloc": 234, "complexity": 72, "token_count": 1648, "diff_parsed": { "added": [ " if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty():", " return 0" ], "deleted": [ " if not sys.stdout.isatty(): return 0" ] } } ] }, { "hash": "63545217c2cdc7f23c7a1bbd3239d0745f738f21", "msg": "added a PWONone global object that can be used in place of Py_None. This is\nuseful because gcc doesn't allow Py_None to be passed into functions with a\nPWOBase& declartion.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-21T07:49:35+00:00", "author_timezone": 0, "committer_date": "2002-09-21T07:49:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "11681370cd203ad5a12c01784892e474d57589f2" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 0, "insertions": 3, "lines": 3, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/common_info.py", "new_path": "weave/common_info.py", "filename": "common_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -10,6 +10,9 @@\n module_support_code = \\\n \"\"\"\n \n+// global None value for use in functions.\n+PWOBase PWONone = PWOBase(Py_None);\n+\n char* find_type(PyObject* py_obj)\n {\n if(py_obj == NULL) return \"C NULL value\";\n", "added_lines": 3, "deleted_lines": 0, "source_code": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\n// global None value for use in functions.\nPWOBase PWONone = PWOBase(Py_None);\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "source_code_before": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 104, "complexity": 0, "token_count": 115, "diff_parsed": { "added": [ "// global None value for use in functions.", "PWOBase PWONone = PWOBase(Py_None);", "" ], "deleted": [] } } ] }, { "hash": "d05f89134d1579964e54d041701899d6447a60ad", "msg": "test_c_spec now tests both msvc and gcc on windows for most of all of the\ncommon converters.\n\nStill need to add tests for new functionality added to underlying SCXX library.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-21T07:53:13+00:00", "author_timezone": 0, "committer_date": "2002-09-21T07:53:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "63545217c2cdc7f23c7a1bbd3239d0745f738f21" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 146, "insertions": 237, "lines": 383, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/tests/test_c_spec.py", "new_path": "weave/tests/test_c_spec.py", "filename": "test_c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,6 +2,14 @@\n import time\n import os,sys\n \n+# Note: test_dir is global to this file. \n+# It is made by setup_test_location()\n+\n+\n+#globals\n+global test_dir \n+test_dir = ''\n+\n from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n \n add_grandparent_to_path(__name__)\n@@ -59,7 +67,6 @@ def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n- test_dir = setup_test_location()\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -81,10 +88,8 @@ def check_var_in(self):\n test(b)\n except TypeError:\n pass\n- teardown_test_location()\n \n def check_int_return(self):\n- test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -99,7 +104,7 @@ def check_int_return(self):\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n- teardown_test_location()\n+\n assert( c == 3)\n \n class test_float_converter(unittest.TestCase): \n@@ -117,11 +122,9 @@ def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n- test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n-\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n@@ -140,10 +143,9 @@ def check_float_var_in(self):\n test(b)\n except TypeError:\n pass\n- teardown_test_location()\n \n- def check_float_return(self):\n- test_dir = setup_test_location() \n+\n+ def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -158,7 +160,6 @@ def check_float_return(self):\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n- teardown_test_location()\n assert( c == 3.)\n \n class test_complex_converter(unittest.TestCase): \n@@ -176,7 +177,6 @@ def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n- test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -198,10 +198,8 @@ def check_complex_var_in(self):\n test(b)\n except TypeError:\n pass\n- teardown_test_location()\n \n def check_complex_return(self):\n- test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -216,53 +214,14 @@ def check_complex_return(self):\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n- teardown_test_location() \n assert( c == 3.+3j)\n \n-class test_msvc_int_converter(test_int_converter): \n- compiler = 'msvc'\n-class test_msvc_float_converter(test_float_converter): \n- compiler = 'msvc'\n-class test_msvc_complex_converter(test_complex_converter): \n- compiler = 'msvc'\n-\n-class test_unix_int_converter(test_int_converter): \n- compiler = ''\n-class test_unix_float_converter(test_float_converter): \n- compiler = ''\n-class test_unix_complex_converter(test_complex_converter): \n- compiler = ''\n-\n-class test_gcc_int_converter(test_int_converter): \n- compiler = 'gcc'\n-class test_gcc_float_converter(test_float_converter): \n- compiler = 'gcc'\n-class test_gcc_complex_converter(test_complex_converter): \n- compiler = 'gcc'\n- \n-def setup_test_location():\n- import tempfile\n- test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n- if not os.path.exists(test_dir):\n- os.mkdir(test_dir)\n- sys.path.insert(0,test_dir) \n- return test_dir\n-\n-def teardown_test_location():\n- import tempfile\n- test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n- if sys.path[0] == test_dir:\n- sys.path = sys.path[1:]\n- return test_dir\n-\n-def remove_file(name):\n- test_dir = os.path.abspath(name)\n-\n #----------------------------------------------------------------------------\n # File conversion tests\n #----------------------------------------------------------------------------\n \n class test_file_converter(unittest.TestCase): \n+ compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n@@ -270,7 +229,7 @@ def check_py_to_file(self):\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n- inline_tools.inline(code,['file']) \n+ inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n@@ -285,7 +244,8 @@ def check_file_to_py(self):\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n- file = inline_tools.inline(code,['file_name'])\n+ file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n+ force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n@@ -303,6 +263,7 @@ class test_instance_converter(unittest.TestCase):\n #----------------------------------------------------------------------------\n \n class test_callable_converter(unittest.TestCase): \n+ compiler=''\n def check_call_function(self):\n import string\n func = string.find\n@@ -312,30 +273,32 @@ def check_call_function(self):\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n PWOTuple args(2);\n- args.setItem(0,PWOString(search_str.c_str()));\n- args.setItem(1,PWOString(sub_str.c_str()));\n+ args.setItem(0,search_str);\n+ args.setItem(1,sub_str);\n return_val = PyObject_CallObject(func,args);\n \"\"\"\n- actual = inline_tools.inline(code,['func','search_str','sub_str'])\n+ actual = inline_tools.inline(code,['func','search_str','sub_str'],\n+ compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n \n-\n class test_sequence_converter(unittest.TestCase): \n+ compiler = ''\n def check_convert_to_dict(self):\n d = {}\n- inline_tools.inline(\"\",['d']) \n+ inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n- inline_tools.inline(\"\",['l']) \n+ inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n- inline_tools.inline(\"\",['s']) \n+ inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n- inline_tools.inline(\"\",['t']) \n+ inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n \n class test_string_converter(unittest.TestCase): \n+ compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n@@ -349,28 +312,33 @@ def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n- mod = ext_tools.ext_module('string_var_in')\n+ mod_name = 'string_var_in'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import string_var_in\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+\n+ exec 'from ' + mod_name + ' import test'\n b='bub'\n- string_var_in.test(b)\n+ test(b)\n try:\n b = 1.\n- string_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n try:\n b = 1\n- string_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n \n def check_return(self):\n- mod = ext_tools.ext_module('string_return')\n+ mod_name = 'string_return'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n@@ -378,13 +346,14 @@ def check_return(self):\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import string_return\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b='bub'\n- c = string_return.test(b)\n+ c = test(b)\n assert( c == 'hello')\n \n class test_list_converter(unittest.TestCase): \n+ compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n@@ -394,44 +363,50 @@ def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n- mod = ext_tools.ext_module('list_var_in')\n+ mod_name = 'list_var_in'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=PWOList();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import list_var_in\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b=[1,2]\n- list_var_in.test(b)\n+ test(b)\n try:\n b = 1.\n- list_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n- list_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n \n def check_return(self):\n- mod = ext_tools.ext_module('list_return')\n+ mod_name = 'list_return'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=PWOList();\n- a.append(PWOString(\"hello\"));\n+ a.append(\"hello\");\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import list_return\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b=[1,2]\n- c = list_return.test(b)\n+ c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n- mod = ext_tools.ext_module('list_speed')\n+ mod_name = 'list_speed'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n PWONumber v = PWONumber();\n@@ -466,15 +441,17 @@ def check_speed(self):\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n- mod.compile()\n- import list_speed\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n- sum1 = list_speed.with_cxx(a)\n+ sum1 = with_cxx(a)\n t2 = time.time()\n+ print 'speed test for list access'\n+ print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n- sum2 = list_speed.no_checking(a)\n+ sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n@@ -489,6 +466,7 @@ def check_speed(self):\n assert( sum1 == sum2 and sum1 == sum3)\n \n class test_tuple_converter(unittest.TestCase): \n+ compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n@@ -498,41 +476,45 @@ def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n- mod = ext_tools.ext_module('tuple_var_in')\n+ mod_name = 'tuple_var_in'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=PWOTuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import tuple_var_in\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b=(1,2)\n- tuple_var_in.test(b)\n+ test(b)\n try:\n b = 1.\n- tuple_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n- tuple_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n \n def check_return(self):\n- mod = ext_tools.ext_module('tuple_return')\n+ mod_name = 'tuple_return'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=PWOTuple(2);\n- a.setItem(0,PWOString(\"hello\"));\n- a.setItem(1,PWOBase(Py_None));\n+ a.setItem(0,\"hello\");\n+ a.setItem(1,PWONone);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import tuple_return\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b=(1,2)\n- c = tuple_return.test(b)\n+ c = test(b)\n assert( c == ('hello',None))\n \n \n@@ -546,28 +528,32 @@ def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n- mod = ext_tools.ext_module('dict_var_in')\n+ mod_name = 'dict_var_in'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=PWODict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import dict_var_in\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b={'y':2}\n- dict_var_in.test(b)\n+ test(b)\n try:\n b = 1.\n- dict_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n- dict_var_in.test(b)\n+ test(b)\n except TypeError:\n pass\n \n def check_return(self):\n- mod = ext_tools.ext_module('dict_return')\n+ mod_name = 'dict_return'+self.compiler\n+ mod_name = unique_mod(test_dir,mod_name)\n+ mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=PWODict();\n@@ -576,52 +562,157 @@ def check_return(self):\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n- mod.compile()\n- import dict_return\n+ mod.compile(location = test_dir, compiler = self.compiler)\n+ exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n- c = dict_return.test(b)\n+ c = test(b)\n assert( c['hello'] == 5)\n+\n+class test_msvc_int_converter(test_int_converter): \n+ compiler = 'msvc'\n+class test_unix_int_converter(test_int_converter): \n+ compiler = ''\n+class test_gcc_int_converter(test_int_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_float_converter(test_float_converter): \n+ compiler = 'msvc'\n+\n+class test_msvc_float_converter(test_float_converter): \n+ compiler = 'msvc'\n+class test_unix_float_converter(test_float_converter): \n+ compiler = ''\n+class test_gcc_float_converter(test_float_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_complex_converter(test_complex_converter): \n+ compiler = 'msvc'\n+class test_unix_complex_converter(test_complex_converter): \n+ compiler = ''\n+class test_gcc_complex_converter(test_complex_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_file_converter(test_file_converter): \n+ compiler = 'msvc'\n+class test_unix_file_converter(test_file_converter): \n+ compiler = ''\n+class test_gcc_file_converter(test_file_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_callable_converter(test_callable_converter): \n+ compiler = 'msvc'\n+class test_unix_callable_converter(test_callable_converter): \n+ compiler = ''\n+class test_gcc_callable_converter(test_callable_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_sequence_converter(test_sequence_converter): \n+ compiler = 'msvc'\n+class test_unix_sequence_converter(test_sequence_converter): \n+ compiler = ''\n+class test_gcc_sequence_converter(test_sequence_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_string_converter(test_string_converter): \n+ compiler = 'msvc'\n+class test_unix_string_converter(test_string_converter): \n+ compiler = ''\n+class test_gcc_string_converter(test_string_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_list_converter(test_list_converter): \n+ compiler = 'msvc'\n+class test_unix_list_converter(test_list_converter): \n+ compiler = ''\n+class test_gcc_list_converter(test_list_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_tuple_converter(test_tuple_converter): \n+ compiler = 'msvc'\n+class test_unix_tuple_converter(test_tuple_converter): \n+ compiler = ''\n+class test_gcc_tuple_converter(test_tuple_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_dict_converter(test_dict_converter): \n+ compiler = 'msvc'\n+class test_unix_dict_converter(test_dict_converter): \n+ compiler = ''\n+class test_gcc_dict_converter(test_dict_converter): \n+ compiler = 'gcc'\n+\n+class test_msvc_instance_converter(test_instance_converter): \n+ compiler = 'msvc'\n+class test_unix_instance_converter(test_instance_converter): \n+ compiler = ''\n+class test_gcc_instance_converter(test_instance_converter): \n+ compiler = 'gcc'\n+ \n+def setup_test_location():\n+ import tempfile\n+ #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n+ test_dir = tempfile.mktemp()\n+ if not os.path.exists(test_dir):\n+ os.mkdir(test_dir)\n+ sys.path.insert(0,test_dir) \n+ return test_dir\n+\n+test_dir = setup_test_location()\n+\n+def teardown_test_location():\n+ import tempfile\n+ test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n+ if sys.path[0] == test_dir:\n+ sys.path = sys.path[1:]\n+ return test_dir\n+\n+def remove_file(name):\n+ test_dir = os.path.abspath(name)\n \n def test_suite(level=1):\n+ from unittest import makeSuite\n+ global test_dir\n+ test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n- \"\"\"\n if msvc_exists():\n- suites.append( unittest.makeSuite(test_msvc_int_converter,\n- 'check_'))\n- suites.append( unittest.makeSuite(test_msvc_float_converter,\n- 'check_')) \n- suites.append( unittest.makeSuite(test_msvc_complex_converter,\n- 'check_'))\n- pass\n+ suites.append( makeSuite(test_msvc_file_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_string_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_list_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_int_converter,'check_'))\n+ suites.append( makeSuite(test_msvc_float_converter,'check_')) \n+ suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n- suites.append( unittest.makeSuite(test_unix_int_converter,\n- 'check_'))\n- suites.append( unittest.makeSuite(test_unix_float_converter,\n- 'check_')) \n- suites.append( unittest.makeSuite(test_unix_complex_converter,\n- 'check_'))\n- \n- if gcc_exists(): \n- suites.append( unittest.makeSuite(test_gcc_int_converter,\n- 'check_'))\n- suites.append( unittest.makeSuite(test_gcc_float_converter,\n- 'check_'))\n- suites.append( unittest.makeSuite(test_gcc_complex_converter,\n- 'check_'))\n-\n- # file, instance, callable object tests\n- suites.append( unittest.makeSuite(test_file_converter,'check_'))\n- suites.append( unittest.makeSuite(test_instance_converter,'check_'))\n- suites.append( unittest.makeSuite(test_callable_converter,'check_'))\n- \"\"\"\n- # sequenc conversion tests\n- suites.append( unittest.makeSuite(test_sequence_converter,'check_'))\n- suites.append( unittest.makeSuite(test_string_converter,'check_'))\n- suites.append( unittest.makeSuite(test_list_converter,'check_'))\n- suites.append( unittest.makeSuite(test_tuple_converter,'check_'))\n- suites.append( unittest.makeSuite(test_dict_converter,'check_'))\n- \n+ suites.append( makeSuite(test_unix_file_converter,'check_'))\n+ suites.append( makeSuite(test_unix_instance_converter,'check_'))\n+ suites.append( makeSuite(test_unix_callable_converter,'check_'))\n+ suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n+ suites.append( makeSuite(test_unix_string_converter,'check_'))\n+ suites.append( makeSuite(test_unix_list_converter,'check_'))\n+ suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n+ suites.append( makeSuite(test_unix_dict_converter,'check_'))\n+ suites.append( makeSuite(test_unix_int_converter,'check_'))\n+ suites.append( makeSuite(test_unix_float_converter,'check_')) \n+ suites.append( makeSuite(test_unix_complex_converter,'check_')) \n+ # run gcc tests also on windows\n+ if gcc_exists() and sys.platform == 'win32': \n+ suites.append( makeSuite(test_gcc_file_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_string_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_list_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_int_converter,'check_'))\n+ suites.append( makeSuite(test_gcc_float_converter,'check_')) \n+ suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n+\n total_suite = unittest.TestSuite(suites)\n return total_suite\n \n", "added_lines": 237, "deleted_lines": 146, "source_code": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n PWOTuple args(2);\n args.setItem(0,search_str);\n args.setItem(1,sub_str);\n return_val = PyObject_CallObject(func,args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=PWOList();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=PWOList();\n a.append(\"hello\");\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n PWONumber v = PWONumber();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=PWOTuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=PWOTuple(2);\n a.setItem(0,\"hello\");\n a.setItem(1,PWONone);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=PWODict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=PWODict();\n a[\"hello\"] = PWONumber(5);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\nimport os,sys\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n test_dir = setup_test_location()\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n teardown_test_location()\n \n def check_int_return(self):\n test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n teardown_test_location()\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n teardown_test_location()\n\n def check_float_return(self):\n test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n teardown_test_location()\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n teardown_test_location()\n\n def check_complex_return(self):\n test_dir = setup_test_location() \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n teardown_test_location() \n assert( c == 3.+3j)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\n\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\n\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file']) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'])\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n PWOTuple args(2);\n args.setItem(0,PWOString(search_str.c_str()));\n args.setItem(1,PWOString(sub_str.c_str()));\n return_val = PyObject_CallObject(func,args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'])\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\n\nclass test_sequence_converter(unittest.TestCase): \n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d']) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l']) \n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s']) \n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t']) \n\nclass test_string_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod = ext_tools.ext_module('string_var_in')\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import string_var_in\n b='bub'\n string_var_in.test(b)\n try:\n b = 1.\n string_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 1\n string_var_in.test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod = ext_tools.ext_module('string_return')\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import string_return\n b='bub'\n c = string_return.test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod = ext_tools.ext_module('list_var_in')\n a = [1]\n code = 'a=PWOList();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import list_var_in\n b=[1,2]\n list_var_in.test(b)\n try:\n b = 1.\n list_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n list_var_in.test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod = ext_tools.ext_module('list_return')\n a = [1]\n code = \"\"\"\n a=PWOList();\n a.append(PWOString(\"hello\"));\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import list_return\n b=[1,2]\n c = list_return.test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod = ext_tools.ext_module('list_speed')\n a = range(1e6);\n code = \"\"\"\n PWONumber v = PWONumber();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile()\n import list_speed\n import time\n t1 = time.time()\n sum1 = list_speed.with_cxx(a)\n t2 = time.time()\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = list_speed.no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod = ext_tools.ext_module('tuple_var_in')\n a = (1,)\n code = 'a=PWOTuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import tuple_var_in\n b=(1,2)\n tuple_var_in.test(b)\n try:\n b = 1.\n tuple_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n tuple_var_in.test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod = ext_tools.ext_module('tuple_return')\n a = (1,)\n code = \"\"\"\n a=PWOTuple(2);\n a.setItem(0,PWOString(\"hello\"));\n a.setItem(1,PWOBase(Py_None));\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import tuple_return\n b=(1,2)\n c = tuple_return.test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod = ext_tools.ext_module('dict_var_in')\n a = {'z':1}\n code = 'a=PWODict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import dict_var_in\n b={'y':2}\n dict_var_in.test(b)\n try:\n b = 1.\n dict_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n dict_var_in.test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod = ext_tools.ext_module('dict_return')\n a = {'z':1}\n code = \"\"\"\n a=PWODict();\n a[\"hello\"] = PWONumber(5);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile()\n import dict_return\n b = {'z':2}\n c = dict_return.test(b)\n assert( c['hello'] == 5)\n \ndef test_suite(level=1):\n suites = [] \n if level >= 5:\n \"\"\"\n if msvc_exists():\n suites.append( unittest.makeSuite(test_msvc_int_converter,\n 'check_'))\n suites.append( unittest.makeSuite(test_msvc_float_converter,\n 'check_')) \n suites.append( unittest.makeSuite(test_msvc_complex_converter,\n 'check_'))\n pass\n else: # unix\n suites.append( unittest.makeSuite(test_unix_int_converter,\n 'check_'))\n suites.append( unittest.makeSuite(test_unix_float_converter,\n 'check_')) \n suites.append( unittest.makeSuite(test_unix_complex_converter,\n 'check_'))\n \n if gcc_exists(): \n suites.append( unittest.makeSuite(test_gcc_int_converter,\n 'check_'))\n suites.append( unittest.makeSuite(test_gcc_float_converter,\n 'check_'))\n suites.append( unittest.makeSuite(test_gcc_complex_converter,\n 'check_'))\n\n # file, instance, callable object tests\n suites.append( unittest.makeSuite(test_file_converter,'check_'))\n suites.append( unittest.makeSuite(test_instance_converter,'check_'))\n suites.append( unittest.makeSuite(test_callable_converter,'check_'))\n \"\"\"\n # sequenc conversion tests\n suites.append( unittest.makeSuite(test_sequence_converter,'check_'))\n suites.append( unittest.makeSuite(test_string_converter,'check_'))\n suites.append( unittest.makeSuite(test_list_converter,'check_'))\n suites.append( unittest.makeSuite(test_tuple_converter,'check_'))\n suites.append( unittest.makeSuite(test_dict_converter,'check_'))\n \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 287, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 308, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 311, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 314, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 362, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 365, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 388, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 470, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 478, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 501, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 522, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 527, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 530, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 553, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 651, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 662, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 672, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 15, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 20, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 27, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 49, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 55, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 24, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 61, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 86, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 113, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 24, "complexity": 3, "token_count": 126, "parameters": [ "self" ], "start_line": 119, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 108, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 169, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 24, "complexity": 3, "token_count": 130, "parameters": [ "self" ], "start_line": 178, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 114, "parameters": [ "self" ], "start_line": 203, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 51, "parameters": [], "start_line": 243, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 251, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 258, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 266, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 277, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 306, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 325, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 328, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 331, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 334, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 339, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 342, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 345, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 348, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 20, "complexity": 3, "token_count": 86, "parameters": [ "self" ], "start_line": 351, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 372, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 388, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 393, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 20, "complexity": 3, "token_count": 92, "parameters": [ "self" ], "start_line": 396, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 417, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 57, "complexity": 4, "token_count": 182, "parameters": [ "self" ], "start_line": 433, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 492, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 20, "complexity": 3, "token_count": 93, "parameters": [ "self" ], "start_line": 500, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 521, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 540, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 545, "end_line": 547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 20, "complexity": 3, "token_count": 94, "parameters": [ "self" ], "start_line": 548, "end_line": 567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 569, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 40, "complexity": 2, "token_count": 92, "parameters": [ "level" ], "start_line": 585, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 628, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 287, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 314, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 672, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 114, "parameters": [ "self" ], "start_line": 203, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 24, "complexity": 3, "token_count": 130, "parameters": [ "self" ], "start_line": 178, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 24, "complexity": 3, "token_count": 126, "parameters": [ "self" ], "start_line": 119, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 651, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 662, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 648, "complexity": 79, "token_count": 3824, "diff_parsed": { "added": [ "# Note: test_dir is global to this file.", "# It is made by setup_test_location()", "", "", "#globals", "global test_dir", "test_dir = ''", "", "", "", " def check_float_return(self):", " compiler = ''", " inline_tools.inline(code,['file'],compiler=self.compiler,force=1)", " file = inline_tools.inline(code,['file_name'], compiler=self.compiler,", " force=1)", " compiler=''", " args.setItem(0,search_str);", " args.setItem(1,sub_str);", " actual = inline_tools.inline(code,['func','search_str','sub_str'],", " compiler=self.compiler,force=1)", " compiler = ''", " inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1)", " inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)", " inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)", " inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)", " compiler = ''", " mod_name = 'string_var_in'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", "", " exec 'from ' + mod_name + ' import test'", " test(b)", " test(b)", " test(b)", " mod_name = 'string_return'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " c = test(b)", " compiler = ''", " mod_name = 'list_var_in'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " test(b)", " test(b)", " test(b)", " mod_name = 'list_return'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " a.append(\"hello\");", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " c = test(b)", " mod_name = 'list_speed'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import with_cxx, no_checking'", " sum1 = with_cxx(a)", " print 'speed test for list access'", " print 'compiler:', self.compiler", " sum2 = no_checking(a)", " compiler = ''", " mod_name = 'tuple_var_in'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " test(b)", " test(b)", " test(b)", " mod_name = 'tuple_return'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " a.setItem(0,\"hello\");", " a.setItem(1,PWONone);", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " c = test(b)", " mod_name = 'dict_var_in'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " test(b)", " test(b)", " test(b)", " mod_name = 'dict_return'+self.compiler", " mod_name = unique_mod(test_dir,mod_name)", " mod = ext_tools.ext_module(mod_name)", " mod.compile(location = test_dir, compiler = self.compiler)", " exec 'from ' + mod_name + ' import test'", " c = test(b)", "", "class test_msvc_int_converter(test_int_converter):", " compiler = 'msvc'", "class test_unix_int_converter(test_int_converter):", " compiler = ''", "class test_gcc_int_converter(test_int_converter):", " compiler = 'gcc'", "", "class test_msvc_float_converter(test_float_converter):", " compiler = 'msvc'", "", "class test_msvc_float_converter(test_float_converter):", " compiler = 'msvc'", "class test_unix_float_converter(test_float_converter):", " compiler = ''", "class test_gcc_float_converter(test_float_converter):", " compiler = 'gcc'", "", "class test_msvc_complex_converter(test_complex_converter):", " compiler = 'msvc'", "class test_unix_complex_converter(test_complex_converter):", " compiler = ''", "class test_gcc_complex_converter(test_complex_converter):", " compiler = 'gcc'", "", "class test_msvc_file_converter(test_file_converter):", " compiler = 'msvc'", "class test_unix_file_converter(test_file_converter):", " compiler = ''", "class test_gcc_file_converter(test_file_converter):", " compiler = 'gcc'", "", "class test_msvc_callable_converter(test_callable_converter):", " compiler = 'msvc'", "class test_unix_callable_converter(test_callable_converter):", " compiler = ''", "class test_gcc_callable_converter(test_callable_converter):", " compiler = 'gcc'", "", "class test_msvc_sequence_converter(test_sequence_converter):", " compiler = 'msvc'", "class test_unix_sequence_converter(test_sequence_converter):", " compiler = ''", "class test_gcc_sequence_converter(test_sequence_converter):", " compiler = 'gcc'", "", "class test_msvc_string_converter(test_string_converter):", " compiler = 'msvc'", "class test_unix_string_converter(test_string_converter):", " compiler = ''", "class test_gcc_string_converter(test_string_converter):", " compiler = 'gcc'", "", "class test_msvc_list_converter(test_list_converter):", " compiler = 'msvc'", "class test_unix_list_converter(test_list_converter):", " compiler = ''", "class test_gcc_list_converter(test_list_converter):", " compiler = 'gcc'", "", "class test_msvc_tuple_converter(test_tuple_converter):", " compiler = 'msvc'", "class test_unix_tuple_converter(test_tuple_converter):", " compiler = ''", "class test_gcc_tuple_converter(test_tuple_converter):", " compiler = 'gcc'", "", "class test_msvc_dict_converter(test_dict_converter):", " compiler = 'msvc'", "class test_unix_dict_converter(test_dict_converter):", " compiler = ''", "class test_gcc_dict_converter(test_dict_converter):", " compiler = 'gcc'", "", "class test_msvc_instance_converter(test_instance_converter):", " compiler = 'msvc'", "class test_unix_instance_converter(test_instance_converter):", " compiler = ''", "class test_gcc_instance_converter(test_instance_converter):", " compiler = 'gcc'", "", "def setup_test_location():", " import tempfile", " #test_dir = os.path.join(tempfile.gettempdir(),'test_files')", " test_dir = tempfile.mktemp()", " if not os.path.exists(test_dir):", " os.mkdir(test_dir)", " sys.path.insert(0,test_dir)", " return test_dir", "", "test_dir = setup_test_location()", "", "def teardown_test_location():", " import tempfile", " test_dir = os.path.join(tempfile.gettempdir(),'test_files')", " if sys.path[0] == test_dir:", " sys.path = sys.path[1:]", " return test_dir", "", "def remove_file(name):", " test_dir = os.path.abspath(name)", " from unittest import makeSuite", " global test_dir", " test_dir = setup_test_location()", " suites.append( makeSuite(test_msvc_file_converter,'check_'))", " suites.append( makeSuite(test_msvc_instance_converter,'check_'))", " suites.append( makeSuite(test_msvc_callable_converter,'check_'))", " suites.append( makeSuite(test_msvc_sequence_converter,'check_'))", " suites.append( makeSuite(test_msvc_string_converter,'check_'))", " suites.append( makeSuite(test_msvc_list_converter,'check_'))", " suites.append( makeSuite(test_msvc_tuple_converter,'check_'))", " suites.append( makeSuite(test_msvc_dict_converter,'check_'))", " suites.append( makeSuite(test_msvc_int_converter,'check_'))", " suites.append( makeSuite(test_msvc_float_converter,'check_'))", " suites.append( makeSuite(test_msvc_complex_converter,'check_'))", " suites.append( makeSuite(test_unix_file_converter,'check_'))", " suites.append( makeSuite(test_unix_instance_converter,'check_'))", " suites.append( makeSuite(test_unix_callable_converter,'check_'))", " suites.append( makeSuite(test_unix_sequence_converter,'check_'))", " suites.append( makeSuite(test_unix_string_converter,'check_'))", " suites.append( makeSuite(test_unix_list_converter,'check_'))", " suites.append( makeSuite(test_unix_tuple_converter,'check_'))", " suites.append( makeSuite(test_unix_dict_converter,'check_'))", " suites.append( makeSuite(test_unix_int_converter,'check_'))", " suites.append( makeSuite(test_unix_float_converter,'check_'))", " suites.append( makeSuite(test_unix_complex_converter,'check_'))", " # run gcc tests also on windows", " if gcc_exists() and sys.platform == 'win32':", " suites.append( makeSuite(test_gcc_file_converter,'check_'))", " suites.append( makeSuite(test_gcc_instance_converter,'check_'))", " suites.append( makeSuite(test_gcc_callable_converter,'check_'))", " suites.append( makeSuite(test_gcc_sequence_converter,'check_'))", " suites.append( makeSuite(test_gcc_string_converter,'check_'))", " suites.append( makeSuite(test_gcc_list_converter,'check_'))", " suites.append( makeSuite(test_gcc_tuple_converter,'check_'))", " suites.append( makeSuite(test_gcc_dict_converter,'check_'))", " suites.append( makeSuite(test_gcc_int_converter,'check_'))", " suites.append( makeSuite(test_gcc_float_converter,'check_'))", " suites.append( makeSuite(test_gcc_complex_converter,'check_'))", "" ], "deleted": [ " test_dir = setup_test_location()", " teardown_test_location()", " test_dir = setup_test_location()", " teardown_test_location()", " test_dir = setup_test_location()", "", " teardown_test_location()", " def check_float_return(self):", " test_dir = setup_test_location()", " teardown_test_location()", " test_dir = setup_test_location()", " teardown_test_location()", " test_dir = setup_test_location()", " teardown_test_location()", "class test_msvc_int_converter(test_int_converter):", " compiler = 'msvc'", "class test_msvc_float_converter(test_float_converter):", " compiler = 'msvc'", "class test_msvc_complex_converter(test_complex_converter):", " compiler = 'msvc'", "", "class test_unix_int_converter(test_int_converter):", " compiler = ''", "class test_unix_float_converter(test_float_converter):", " compiler = ''", "class test_unix_complex_converter(test_complex_converter):", " compiler = ''", "", "class test_gcc_int_converter(test_int_converter):", " compiler = 'gcc'", "class test_gcc_float_converter(test_float_converter):", " compiler = 'gcc'", "class test_gcc_complex_converter(test_complex_converter):", " compiler = 'gcc'", "", "def setup_test_location():", " import tempfile", " test_dir = os.path.join(tempfile.gettempdir(),'test_files')", " if not os.path.exists(test_dir):", " os.mkdir(test_dir)", " sys.path.insert(0,test_dir)", " return test_dir", "", "def teardown_test_location():", " import tempfile", " test_dir = os.path.join(tempfile.gettempdir(),'test_files')", " if sys.path[0] == test_dir:", " sys.path = sys.path[1:]", " return test_dir", "", "def remove_file(name):", " test_dir = os.path.abspath(name)", "", " inline_tools.inline(code,['file'])", " file = inline_tools.inline(code,['file_name'])", " args.setItem(0,PWOString(search_str.c_str()));", " args.setItem(1,PWOString(sub_str.c_str()));", " actual = inline_tools.inline(code,['func','search_str','sub_str'])", "", " inline_tools.inline(\"\",['d'])", " inline_tools.inline(\"\",['l'])", " inline_tools.inline(\"\",['s'])", " inline_tools.inline(\"\",['t'])", " mod = ext_tools.ext_module('string_var_in')", " mod.compile()", " import string_var_in", " string_var_in.test(b)", " string_var_in.test(b)", " string_var_in.test(b)", " mod = ext_tools.ext_module('string_return')", " mod.compile()", " import string_return", " c = string_return.test(b)", " mod = ext_tools.ext_module('list_var_in')", " mod.compile()", " import list_var_in", " list_var_in.test(b)", " list_var_in.test(b)", " list_var_in.test(b)", " mod = ext_tools.ext_module('list_return')", " a.append(PWOString(\"hello\"));", " mod.compile()", " import list_return", " c = list_return.test(b)", " mod = ext_tools.ext_module('list_speed')", " mod.compile()", " import list_speed", " sum1 = list_speed.with_cxx(a)", " sum2 = list_speed.no_checking(a)", " mod = ext_tools.ext_module('tuple_var_in')", " mod.compile()", " import tuple_var_in", " tuple_var_in.test(b)", " tuple_var_in.test(b)", " tuple_var_in.test(b)", " mod = ext_tools.ext_module('tuple_return')", " a.setItem(0,PWOString(\"hello\"));", " a.setItem(1,PWOBase(Py_None));", " mod.compile()", " import tuple_return", " c = tuple_return.test(b)", " mod = ext_tools.ext_module('dict_var_in')", " mod.compile()", " import dict_var_in", " dict_var_in.test(b)", " dict_var_in.test(b)", " dict_var_in.test(b)", " mod = ext_tools.ext_module('dict_return')", " mod.compile()", " import dict_return", " c = dict_return.test(b)", " \"\"\"", " suites.append( unittest.makeSuite(test_msvc_int_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_msvc_float_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_msvc_complex_converter,", " 'check_'))", " pass", " suites.append( unittest.makeSuite(test_unix_int_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_unix_float_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_unix_complex_converter,", " 'check_'))", "", " if gcc_exists():", " suites.append( unittest.makeSuite(test_gcc_int_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_gcc_float_converter,", " 'check_'))", " suites.append( unittest.makeSuite(test_gcc_complex_converter,", " 'check_'))", "", " # file, instance, callable object tests", " suites.append( unittest.makeSuite(test_file_converter,'check_'))", " suites.append( unittest.makeSuite(test_instance_converter,'check_'))", " suites.append( unittest.makeSuite(test_callable_converter,'check_'))", " \"\"\"", " # sequenc conversion tests", " suites.append( unittest.makeSuite(test_sequence_converter,'check_'))", " suites.append( unittest.makeSuite(test_string_converter,'check_'))", " suites.append( unittest.makeSuite(test_list_converter,'check_'))", " suites.append( unittest.makeSuite(test_tuple_converter,'check_'))", " suites.append( unittest.makeSuite(test_dict_converter,'check_'))", "" ] } } ] }, { "hash": "f9d16bb476e271f28b70130c7d3cae73d2bd074e", "msg": "Significant functionality added.\n\nMethods such as setItem, in, insert, append, and xxxMmbr::operator= were\noverloaded to accept basic types int, double, char*, and std::string. This\nallows for much more Pythonic looking C++ code.\n\n!! Need to add same functionality for mappings on haskey and maybe a few\n!! others.\n\n!! Need a set of unit tests for added functions to make sure reference\n!! counting is handled correctly.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-21T07:56:57+00:00", "author_timezone": 0, "committer_date": "2002-09-21T07:56:57+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d05f89134d1579964e54d041701899d6447a60ad" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 0, "insertions": 187, "lines": 187, "files": 3, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/scxx/PWOImp.cpp", "new_path": "weave/scxx/PWOImp.cpp", "filename": "PWOImp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -17,8 +17,107 @@ void PWOBase::GrabRef(PyObject* newObj)\n _own = _obj = newObj;\n }\n \n+bool PWOSequence::in(int value) {\n+ PWOBase val = PWONumber(value);\n+ return in(val);\n+};\n+ \n+bool PWOSequence::in(double value) {\n+ PWOBase val = PWONumber(value);\n+ return in(val);\n+};\n+\n+bool PWOSequence::in(char* value) {\n+ PWOBase val = PWOString(value);\n+ return in(val);\n+};\n+\n+bool PWOSequence::in(std::string value) {\n+ PWOBase val = PWOString(value.c_str());\n+ return in(val);\n+};\n+ \n+int PWOSequence::count(int value) const {\n+ PWONumber val = PWONumber(value);\n+ return count(val);\n+};\n+\n+int PWOSequence::count(double value) const {\n+ PWONumber val = PWONumber(value);\n+ return count(val);\n+};\n+\n+int PWOSequence::count(char* value) const {\n+ PWOString val = PWOString(value);\n+ return count(val);\n+};\n+\n+int PWOSequence::count(std::string value) const {\n+ PWOString val = PWOString(value.c_str());\n+ return count(val);\n+};\n+\n+int PWOSequence::index(int value) const {\n+ PWONumber val = PWONumber(value);\n+ return index(val);\n+};\n+\n+int PWOSequence::index(double value) const {\n+ PWONumber val = PWONumber(value);\n+ return index(val);\n+};\n+int PWOSequence::index(char* value) const {\n+ PWOString val = PWOString(value);\n+ return index(val);\n+};\n+\n+int PWOSequence::index(std::string value) const {\n+ PWOString val = PWOString(value.c_str());\n+ return index(val);\n+};\n+\n PWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n+ \n+PWOList& PWOList::append(int other) {\n+ PWONumber oth = PWONumber(other);\n+ return append(oth);\n+};\n+ \n+PWOList& PWOList::append(double other) {\n+ PWONumber oth = PWONumber(other);\n+ return append(oth);\n+};\n+\n+PWOList& PWOList::append(char* other) {\n+ PWOString oth = PWOString(other);\n+ return append(oth);\n+};\n+\n+PWOList& PWOList::append(std::string other) {\n+ PWOString oth = PWOString(other.c_str());\n+ return append(oth);\n+};\n+\n+PWOList& PWOList::insert(int ndx, int other) {\n+ PWONumber oth = PWONumber(other);\n+ return insert(ndx, other);\n+};\n+\n+PWOList& PWOList::insert(int ndx, double other) {\n+ PWONumber oth = PWONumber(other);\n+ return insert(ndx, other);\n+};\n+\n+PWOList& PWOList::insert(int ndx, char* other) {\n+ PWOString oth = PWOString(other);\n+ return insert(ndx, other);\n+};\n+\n+PWOList& PWOList::insert(int ndx, std::string other) {\n+ PWOString oth = PWOString(other.c_str());\n+ return insert(ndx, other);\n+};\n \n PWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n", "added_lines": 99, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"PWOSequence.h\"\n#include \"PWOMSequence.h\"\n#include \"PWOMapping.h\"\n#include \"PWOCallable.h\"\n#include \"PWONumber.h\"\n\n // incref new owner, and decref old owner, and adjust to new owner\nvoid PWOBase::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nbool PWOSequence::in(int value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n \nbool PWOSequence::in(double value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n\nbool PWOSequence::in(char* value) {\n PWOBase val = PWOString(value);\n return in(val);\n};\n\nbool PWOSequence::in(std::string value) {\n PWOBase val = PWOString(value.c_str());\n return in(val);\n};\n \nint PWOSequence::count(int value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(double value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(char* value) const {\n PWOString val = PWOString(value);\n return count(val);\n};\n\nint PWOSequence::count(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return count(val);\n};\n\nint PWOSequence::index(int value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\n\nint PWOSequence::index(double value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\nint PWOSequence::index(char* value) const {\n PWOString val = PWOString(value);\n return index(val);\n};\n\nint PWOSequence::index(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return index(val);\n};\n\nPWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n \nPWOList& PWOList::append(int other) {\n PWONumber oth = PWONumber(other);\n return append(oth);\n};\n \nPWOList& PWOList::append(double other) {\n PWONumber oth = PWONumber(other);\n return append(oth);\n};\n\nPWOList& PWOList::append(char* other) {\n PWOString oth = PWOString(other);\n return append(oth);\n};\n\nPWOList& PWOList::append(std::string other) {\n PWOString oth = PWOString(other.c_str());\n return append(oth);\n};\n\nPWOList& PWOList::insert(int ndx, int other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, double other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, char* other) {\n PWOString oth = PWOString(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, std::string other) {\n PWOString oth = PWOString(other.c_str());\n return insert(ndx, other);\n};\n\nPWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOBase PWOCallable::call() const {\n static PWOTuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"PWOSequence.h\"\n#include \"PWOMSequence.h\"\n#include \"PWOMapping.h\"\n#include \"PWOCallable.h\"\n#include \"PWONumber.h\"\n\n // incref new owner, and decref old owner, and adjust to new owner\nvoid PWOBase::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nPWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n\nPWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOBase PWOCallable::call() const {\n static PWOTuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "methods": [ { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 102, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 107, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 117, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 125, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 132, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 156, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 162, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 168, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 186, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 192, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 198, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 205, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 218, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 23, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 26, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 33, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 45, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 51, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 57, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 63, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 69, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 75, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 81, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 87, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 93, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 99, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 117, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 107, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 102, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "nloc": 179, "complexity": 42, "token_count": 1229, "diff_parsed": { "added": [ "bool PWOSequence::in(int value) {", " PWOBase val = PWONumber(value);", " return in(val);", "};", "", "bool PWOSequence::in(double value) {", " PWOBase val = PWONumber(value);", " return in(val);", "};", "", "bool PWOSequence::in(char* value) {", " PWOBase val = PWOString(value);", " return in(val);", "};", "", "bool PWOSequence::in(std::string value) {", " PWOBase val = PWOString(value.c_str());", " return in(val);", "};", "", "int PWOSequence::count(int value) const {", " PWONumber val = PWONumber(value);", " return count(val);", "};", "", "int PWOSequence::count(double value) const {", " PWONumber val = PWONumber(value);", " return count(val);", "};", "", "int PWOSequence::count(char* value) const {", " PWOString val = PWOString(value);", " return count(val);", "};", "", "int PWOSequence::count(std::string value) const {", " PWOString val = PWOString(value.c_str());", " return count(val);", "};", "", "int PWOSequence::index(int value) const {", " PWONumber val = PWONumber(value);", " return index(val);", "};", "", "int PWOSequence::index(double value) const {", " PWONumber val = PWONumber(value);", " return index(val);", "};", "int PWOSequence::index(char* value) const {", " PWOString val = PWOString(value);", " return index(val);", "};", "", "int PWOSequence::index(std::string value) const {", " PWOString val = PWOString(value.c_str());", " return index(val);", "};", "", "", "PWOList& PWOList::append(int other) {", " PWONumber oth = PWONumber(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(double other) {", " PWONumber oth = PWONumber(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(char* other) {", " PWOString oth = PWOString(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(std::string other) {", " PWOString oth = PWOString(other.c_str());", " return append(oth);", "};", "", "PWOList& PWOList::insert(int ndx, int other) {", " PWONumber oth = PWONumber(other);", " return insert(ndx, other);", "};", "", "PWOList& PWOList::insert(int ndx, double other) {", " PWONumber oth = PWONumber(other);", " return insert(ndx, other);", "};", "", "PWOList& PWOList::insert(int ndx, char* other) {", " PWOString oth = PWOString(other);", " return insert(ndx, other);", "};", "", "PWOList& PWOList::insert(int ndx, std::string other) {", " PWOString oth = PWOString(other.c_str());", " return insert(ndx, other);", "};" ], "deleted": [] } }, { "old_path": "weave/scxx/PWOMSequence.h", "new_path": "weave/scxx/PWOMSequence.h", "filename": "PWOMSequence.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -87,12 +87,42 @@ public:\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n+\n+ void setItem(int ndx, int val) {\n+ //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n+ int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+ \n+ void setItem(int ndx, double val) {\n+ //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n+ int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void setItem(int ndx, char* val) {\n+ //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n+ int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void setItem(int ndx, std::string val) {\n+ //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n+ int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n+ \n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n@@ -102,6 +132,11 @@ public:\n };\n return *this;\n };\n+ PWOList& append(int other);\n+ PWOList& append(double other);\n+ PWOList& append(char* other);\n+ PWOList& append(std::string other);\n+\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n@@ -121,6 +156,11 @@ public:\n };\n return *this;\n };\n+ PWOList& insert(int ndx, int other);\n+ PWOList& insert(int ndx, double other);\n+ PWOList& insert(int ndx, char* other); \n+ PWOList& insert(int ndx, std::string other);\n+\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n", "added_lines": 40, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n#define PWOMSEQUENCE_H_INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \n\n\nclass PWOList;\n\nclass PWOListMmbr : public PWOBase\n{\n PWOList& _parent;\n int _ndx;\npublic:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n PWOListMmbr& operator=(int other);\n PWOListMmbr& operator=(float other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n};\n\nclass PWOList : public PWOSequence\n{\npublic:\n PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n PWOList(const PWOList& other) : PWOSequence(other) {};\n PWOList(PyObject* obj) : PWOSequence(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOList() {};\n\n virtual PWOList& operator=(const PWOList& other) {\n GrabRef(other);\n return *this;\n };\n PWOList& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool delItem(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool delSlice(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOListMmbr operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return PWOListMmbr(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void setItem(int ndx, PWOBase& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, int val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, double val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n \n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n };\n return *this;\n };\n PWOList& append(int other);\n PWOList& append(double other);\n PWOList& append(char* other);\n PWOList& append(std::string other);\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n PWOList& insert(int ndx, PWOBase& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n PWOList& insert(int ndx, int other);\n PWOList& insert(int ndx, double other);\n PWOList& insert(int ndx, char* other); \n PWOList& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n PWOList& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n};\n\n#endif // PWOMSEQUENCE_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n#define PWOMSEQUENCE_H_INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \n\n\nclass PWOList;\n\nclass PWOListMmbr : public PWOBase\n{\n PWOList& _parent;\n int _ndx;\npublic:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n PWOListMmbr& operator=(int other);\n PWOListMmbr& operator=(float other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n};\n\nclass PWOList : public PWOSequence\n{\npublic:\n PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n PWOList(const PWOList& other) : PWOSequence(other) {};\n PWOList(PyObject* obj) : PWOSequence(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOList() {};\n\n virtual PWOList& operator=(const PWOList& other) {\n GrabRef(other);\n return *this;\n };\n PWOList& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool delItem(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool delSlice(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOListMmbr operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return PWOListMmbr(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void setItem(int ndx, PWOBase& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n };\n return *this;\n };\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n PWOList& insert(int ndx, PWOBase& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n PWOList& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n};\n\n#endif // PWOMSEQUENCE_H_INCLUDED_\n", "methods": [ { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 120, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 44, "parameters": [ "other" ], "start_line": 127, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 151, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 178, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "methods_before": [ { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 91, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 44, "parameters": [ "other" ], "start_line": 97, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 116, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 126, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 138, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 130, "complexity": 34, "token_count": 891, "diff_parsed": { "added": [ "", " void setItem(int ndx, int val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, double val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, char* val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, std::string val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", "", " PWOList& append(int other);", " PWOList& append(double other);", " PWOList& append(char* other);", " PWOList& append(std::string other);", "", " PWOList& insert(int ndx, int other);", " PWOList& insert(int ndx, double other);", " PWOList& insert(int ndx, char* other);", " PWOList& insert(int ndx, std::string other);", "" ], "deleted": [] } }, { "old_path": "weave/scxx/PWOSequence.h", "new_path": "weave/scxx/PWOSequence.h", "filename": "PWOSequence.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -5,11 +5,14 @@\n #if !defined(PWOSEQUENCE_H_INCLUDED_)\n #define PWOSEQUENCE_H_INCLUDED_\n \n+#include \n #include \"PWOBase.h\"\n \n // This isn't being picked up out of PWOBase.h for some reason\n void Fail(PyObject*, const char* msg);\n \n+class PWOString;\n+\n class PWOSequence : public PWOBase\n {\n public:\n@@ -42,6 +45,7 @@ public:\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n+\n //PySequence_Count\n int count(const PWOBase& value) const {\n int rslt = PySequence_Count(_obj, value);\n@@ -49,6 +53,12 @@ public:\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n+\n+ int count(int value) const;\n+ int count(double value) const; \n+ int count(char* value) const;\n+ int count(std::string value) const;\n+ \n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOBase operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n@@ -71,6 +81,12 @@ public:\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n+ \n+ bool in(int value); \n+ bool in(double value);\n+ bool in(char* value);\n+ bool in(std::string value);\n+ \n //PySequence_Index\n int index(const PWOBase& value) const {\n int rslt = PySequence_Index(_obj, value);\n@@ -78,6 +94,11 @@ public:\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n+ int index(int value) const;\n+ int index(double value) const;\n+ int index(char* value) const;\n+ int index(std::string value) const; \n+ \n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n@@ -128,8 +149,35 @@ public:\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n+ \n+ // ej: additions\n+ void setItem(int ndx, int val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void setItem(int ndx, double val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void setItem(int ndx, char* val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void setItem(int ndx, std::string val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+ // ej: end additions\n };\n \n+\n class PWOString : public PWOSequence\n {\n public:\n", "added_lines": 48, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOSEQUENCE_H_INCLUDED_)\n#define PWOSEQUENCE_H_INCLUDED_\n\n#include \n#include \"PWOBase.h\"\n\n// This isn't being picked up out of PWOBase.h for some reason\nvoid Fail(PyObject*, const char* msg);\n\nclass PWOString;\n\nclass PWOSequence : public PWOBase\n{\npublic:\n PWOSequence() : PWOBase() {};\n PWOSequence(const PWOSequence& other) : PWOBase(other) {};\n PWOSequence(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOSequence() {}\n\n virtual PWOSequence& operator=(const PWOSequence& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOSequence& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n //PySequence_Concat\n PWOSequence operator+(const PWOSequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n\n //PySequence_Count\n int count(const PWOBase& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOBase operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n if (o == 0)\n Fail(PyExc_IndexError, \"index out of range\");\n return LoseRef(o);\n };\n //PySequence_GetSlice\n //virtual PWOSequence& operator [] (PWSlice& x) {...};\n PWOSequence getSlice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n Fail(PyExc_IndexError, \"could not obtain slice\");\n return LoseRef(o);\n };\n //PySequence_In\n bool in(const PWOBase& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n \n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n //PySequence_Index\n int index(const PWOBase& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n };\n // added length for compatibility with std::string.\n int length() const {\n return PySequence_Length(_obj);\n };\n //PySequence_Repeat\n PWOSequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return LoseRef(rslt);\n };\n //PySequence_Tuple\n};\n\nclass PWOList;\n\nclass PWOTuple : public PWOSequence\n{\npublic:\n PWOTuple(int sz=0) : PWOSequence (PyTuple_New(sz)) { LoseRef(_obj); }\n PWOTuple(const PWOTuple& other) : PWOSequence(other) { }\n PWOTuple(PyObject* obj) : PWOSequence(obj) { _violentTypeCheck(); }\n PWOTuple(const PWOList& list);\n virtual ~PWOTuple() {};\n\n virtual PWOTuple& operator=(const PWOTuple& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOTuple& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n void setItem(int ndx, PWOBase& val) {\n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n // ej: additions\n void setItem(int ndx, int val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, double val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n // ej: end additions\n};\n\n\nclass PWOString : public PWOSequence\n{\npublic:\n PWOString() : PWOSequence() {};\n PWOString(const char* s)\n : PWOSequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n PWOString(const char* s, int sz)\n : PWOSequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n PWOString(const PWOString& other)\n : PWOSequence(other) {};\n PWOString(PyObject* obj)\n : PWOSequence(obj) { _violentTypeCheck(); };\n PWOString(const PWOBase& other)\n : PWOSequence(other) { _violentTypeCheck(); };\n virtual ~PWOString() {};\n\n virtual PWOString& operator=(const PWOString& other) {\n GrabRef(other);\n return *this;\n };\n PWOString& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n static PWOString format(const PWOString& fmt, PWOTuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"string format failed\");\n return LoseRef(rslt);\n };\n};\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOSEQUENCE_H_INCLUDED_)\n#define PWOSEQUENCE_H_INCLUDED_\n\n#include \"PWOBase.h\"\n\n// This isn't being picked up out of PWOBase.h for some reason\nvoid Fail(PyObject*, const char* msg);\n\nclass PWOSequence : public PWOBase\n{\npublic:\n PWOSequence() : PWOBase() {};\n PWOSequence(const PWOSequence& other) : PWOBase(other) {};\n PWOSequence(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOSequence() {}\n\n virtual PWOSequence& operator=(const PWOSequence& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOSequence& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n //PySequence_Concat\n PWOSequence operator+(const PWOSequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n //PySequence_Count\n int count(const PWOBase& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOBase operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n if (o == 0)\n Fail(PyExc_IndexError, \"index out of range\");\n return LoseRef(o);\n };\n //PySequence_GetSlice\n //virtual PWOSequence& operator [] (PWSlice& x) {...};\n PWOSequence getSlice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n Fail(PyExc_IndexError, \"could not obtain slice\");\n return LoseRef(o);\n };\n //PySequence_In\n bool in(const PWOBase& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n //PySequence_Index\n int index(const PWOBase& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n };\n // added length for compatibility with std::string.\n int length() const {\n return PySequence_Length(_obj);\n };\n //PySequence_Repeat\n PWOSequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return LoseRef(rslt);\n };\n //PySequence_Tuple\n};\n\nclass PWOList;\n\nclass PWOTuple : public PWOSequence\n{\npublic:\n PWOTuple(int sz=0) : PWOSequence (PyTuple_New(sz)) { LoseRef(_obj); }\n PWOTuple(const PWOTuple& other) : PWOSequence(other) { }\n PWOTuple(PyObject* obj) : PWOSequence(obj) { _violentTypeCheck(); }\n PWOTuple(const PWOList& list);\n virtual ~PWOTuple() {};\n\n virtual PWOTuple& operator=(const PWOTuple& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOTuple& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n void setItem(int ndx, PWOBase& val) {\n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n};\n\nclass PWOString : public PWOSequence\n{\npublic:\n PWOString() : PWOSequence() {};\n PWOString(const char* s)\n : PWOSequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n PWOString(const char* s, int sz)\n : PWOSequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n PWOString(const PWOString& other)\n : PWOSequence(other) {};\n PWOString(PyObject* obj)\n : PWOSequence(obj) { _violentTypeCheck(); };\n PWOString(const PWOBase& other)\n : PWOSequence(other) { _violentTypeCheck(); };\n virtual ~PWOString() {};\n\n virtual PWOString& operator=(const PWOString& other) {\n GrabRef(other);\n return *this;\n };\n PWOString& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n static PWOString format(const PWOString& fmt, PWOTuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"string format failed\");\n return LoseRef(rslt);\n };\n};\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "methods": [ { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::~PWOSequence", "long_name": "PWOSequence::~PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::_violentTypeCheck", "long_name": "PWOSequence::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator +", "long_name": "PWOSequence::operator +( const PWOSequence & rhs) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator [ ]", "long_name": "PWOSequence::operator [ ]( int i) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::getSlice", "long_name": "PWOSequence::getSlice( int lo , int hi) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::len", "long_name": "PWOSequence::len() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::length", "long_name": "PWOSequence::length() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::operator *", "long_name": "PWOSequence::operator *( int count) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 111, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( int sz = 0)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 125, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 126, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 127, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::~PWOTuple", "long_name": "PWOTuple::~PWOTuple()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 129, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 131, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::_violentTypeCheck", "long_name": "PWOTuple::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , PWOBase & val)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 146, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , int val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , double val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 160, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , char * val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , std :: string val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 172, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 184, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 185, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s , int sz)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 187, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::~PWOString", "long_name": "PWOString::~PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 195, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 201, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::_violentTypeCheck", "long_name": "PWOString::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 206, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::operator const char *", "long_name": "PWOString::operator const char *() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 212, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOString::format", "long_name": "PWOString::format( const PWOString & fmt , PWOTuple & args)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "fmt", "args" ], "start_line": 215, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "methods_before": [ { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 16, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 18, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::~PWOSequence", "long_name": "PWOSequence::~PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 27, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::_violentTypeCheck", "long_name": "PWOSequence::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 32, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator +", "long_name": "PWOSequence::operator +( const PWOSequence & rhs) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator [ ]", "long_name": "PWOSequence::operator [ ]( int i) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::getSlice", "long_name": "PWOSequence::getSlice( int lo , int hi) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 75, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::len", "long_name": "PWOSequence::len() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::length", "long_name": "PWOSequence::length() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::operator *", "long_name": "PWOSequence::operator *( int count) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 90, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( int sz = 0)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 104, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 105, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 106, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::~PWOTuple", "long_name": "PWOTuple::~PWOTuple()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 108, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 110, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 114, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::_violentTypeCheck", "long_name": "PWOTuple::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , PWOBase & val)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 125, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 136, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s , int sz)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 139, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 145, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::~PWOString", "long_name": "PWOString::~PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 147, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 149, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::_violentTypeCheck", "long_name": "PWOString::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::operator const char *", "long_name": "PWOString::operator const char *() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOString::format", "long_name": "PWOString::format( const PWOString & fmt , PWOTuple & args)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "fmt", "args" ], "start_line": 167, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , std :: string val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 172, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , char * val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , double val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 160, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , int val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 180, "complexity": 56, "token_count": 1231, "diff_parsed": { "added": [ "#include ", "class PWOString;", "", "", "", " int count(int value) const;", " int count(double value) const;", " int count(char* value) const;", " int count(std::string value) const;", "", "", " bool in(int value);", " bool in(double value);", " bool in(char* value);", " bool in(std::string value);", "", " int index(int value) const;", " int index(double value) const;", " int index(char* value) const;", " int index(std::string value) const;", "", "", " // ej: additions", " void setItem(int ndx, int val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, double val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, char* val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, std::string val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", " // ej: end additions", "" ], "deleted": [] } } ] }, { "hash": "ccc5a06bd857e3e6de81b1a18b3959e3ceacf4aa", "msg": "weave now uses a modified version of scxx. The new class names are closer\nto (identical in most cases) to the boost library naming convention. We\nwill continue to try and make code as close to boost compatible as we can\nwithout getting into templates. Here are the main changes:\n\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each\n exposed class in its own header file.\n PWOBase -> py::object -- object.h\n PWOList -> py::list -- list.h\n PWOTuple -> py::tuple -- tuple.h\n PWOMapping -> py::dict -- dict.h\n PWOCallable -> py::callable -- callable.h\n PWOString -> py::str -- str.h\n PWONumber -> py::number -- number.h", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-23T08:07:30+00:00", "author_timezone": 0, "committer_date": "2002-09-23T08:07:30+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f9d16bb476e271f28b70130c7d3cae73d2bd074e" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 45, "insertions": 1564, "lines": 1609, "files": 14, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.9835294117647059, "modified_files": [ { "old_path": "weave/scxx/PWOImp.cpp", "new_path": "weave/scxx/PWOImp.cpp", "filename": "PWOImp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -79,44 +79,24 @@ int PWOSequence::index(std::string value) const {\n PWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n \n-PWOList& PWOList::append(int other) {\n- PWONumber oth = PWONumber(other);\n- return append(oth);\n-};\n- \n-PWOList& PWOList::append(double other) {\n- PWONumber oth = PWONumber(other);\n- return append(oth);\n-};\n-\n-PWOList& PWOList::append(char* other) {\n- PWOString oth = PWOString(other);\n- return append(oth);\n-};\n-\n-PWOList& PWOList::append(std::string other) {\n- PWOString oth = PWOString(other.c_str());\n- return append(oth);\n-};\n-\n PWOList& PWOList::insert(int ndx, int other) {\n PWONumber oth = PWONumber(other);\n- return insert(ndx, other);\n+ return insert(ndx, oth);\n };\n \n PWOList& PWOList::insert(int ndx, double other) {\n PWONumber oth = PWONumber(other);\n- return insert(ndx, other);\n+ return insert(ndx, oth);\n };\n \n PWOList& PWOList::insert(int ndx, char* other) {\n PWOString oth = PWOString(other);\n- return insert(ndx, other);\n+ return insert(ndx, oth);\n };\n \n PWOList& PWOList::insert(int ndx, std::string other) {\n PWOString oth = PWOString(other.c_str());\n- return insert(ndx, other);\n+ return insert(ndx, oth);\n };\n \n PWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n@@ -129,13 +109,14 @@ PWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n return *this;\n }\n \n-PWOListMmbr& PWOListMmbr::operator=(int other) {\n- GrabRef(PWONumber(other));\n+PWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {\n+ GrabRef(other);\n+ //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n }\n \n-PWOListMmbr& PWOListMmbr::operator=(float other) {\n+PWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n@@ -171,12 +152,6 @@ PWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n return *this;\n }\n \n-PWOMappingMmbr& PWOMappingMmbr::operator=(float other) {\n- GrabRef(PWONumber(other));\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n PWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n", "added_lines": 8, "deleted_lines": 33, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"PWOSequence.h\"\n#include \"PWOMSequence.h\"\n#include \"PWOMapping.h\"\n#include \"PWOCallable.h\"\n#include \"PWONumber.h\"\n\n // incref new owner, and decref old owner, and adjust to new owner\nvoid PWOBase::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nbool PWOSequence::in(int value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n \nbool PWOSequence::in(double value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n\nbool PWOSequence::in(char* value) {\n PWOBase val = PWOString(value);\n return in(val);\n};\n\nbool PWOSequence::in(std::string value) {\n PWOBase val = PWOString(value.c_str());\n return in(val);\n};\n \nint PWOSequence::count(int value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(double value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(char* value) const {\n PWOString val = PWOString(value);\n return count(val);\n};\n\nint PWOSequence::count(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return count(val);\n};\n\nint PWOSequence::index(int value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\n\nint PWOSequence::index(double value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\nint PWOSequence::index(char* value) const {\n PWOString val = PWOString(value);\n return index(val);\n};\n\nint PWOSequence::index(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return index(val);\n};\n\nPWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n \nPWOList& PWOList::insert(int ndx, int other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, double other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, char* other) {\n PWOString oth = PWOString(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, std::string other) {\n PWOString oth = PWOString(other.c_str());\n return insert(ndx, oth);\n};\n\nPWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOBase PWOCallable::call() const {\n static PWOTuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"PWOSequence.h\"\n#include \"PWOMSequence.h\"\n#include \"PWOMapping.h\"\n#include \"PWOCallable.h\"\n#include \"PWONumber.h\"\n\n // incref new owner, and decref old owner, and adjust to new owner\nvoid PWOBase::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nbool PWOSequence::in(int value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n \nbool PWOSequence::in(double value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n\nbool PWOSequence::in(char* value) {\n PWOBase val = PWOString(value);\n return in(val);\n};\n\nbool PWOSequence::in(std::string value) {\n PWOBase val = PWOString(value.c_str());\n return in(val);\n};\n \nint PWOSequence::count(int value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(double value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(char* value) const {\n PWOString val = PWOString(value);\n return count(val);\n};\n\nint PWOSequence::count(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return count(val);\n};\n\nint PWOSequence::index(int value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\n\nint PWOSequence::index(double value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\nint PWOSequence::index(char* value) const {\n PWOString val = PWOString(value);\n return index(val);\n};\n\nint PWOSequence::index(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return index(val);\n};\n\nPWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n \nPWOList& PWOList::append(int other) {\n PWONumber oth = PWONumber(other);\n return append(oth);\n};\n \nPWOList& PWOList::append(double other) {\n PWONumber oth = PWONumber(other);\n return append(oth);\n};\n\nPWOList& PWOList::append(char* other) {\n PWOString oth = PWOString(other);\n return append(oth);\n};\n\nPWOList& PWOList::append(std::string other) {\n PWOString oth = PWOString(other.c_str());\n return append(oth);\n};\n\nPWOList& PWOList::insert(int ndx, int other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, double other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, char* other) {\n PWOString oth = PWOString(other);\n return insert(ndx, other);\n};\n\nPWOList& PWOList::insert(int ndx, std::string other) {\n PWOString oth = PWOString(other.c_str());\n return insert(ndx, other);\n};\n\nPWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(float other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOBase PWOCallable::call() const {\n static PWOTuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "methods": [ { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOListMmbr & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 143, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 155, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 161, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 186, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 102, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 107, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 117, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 125, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 132, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 156, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 162, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 168, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 186, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 192, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 198, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 205, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 218, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOListMmbr & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( float other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 158, "complexity": 37, "token_count": 1083, "diff_parsed": { "added": [ " return insert(ndx, oth);", " return insert(ndx, oth);", " return insert(ndx, oth);", " return insert(ndx, oth);", "PWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for setItem to steal", "PWOListMmbr& PWOListMmbr::operator=(int other) {" ], "deleted": [ "PWOList& PWOList::append(int other) {", " PWONumber oth = PWONumber(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(double other) {", " PWONumber oth = PWONumber(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(char* other) {", " PWOString oth = PWOString(other);", " return append(oth);", "};", "", "PWOList& PWOList::append(std::string other) {", " PWOString oth = PWOString(other.c_str());", " return append(oth);", "};", "", " return insert(ndx, other);", " return insert(ndx, other);", " return insert(ndx, other);", " return insert(ndx, other);", "PWOListMmbr& PWOListMmbr::operator=(int other) {", " GrabRef(PWONumber(other));", "PWOListMmbr& PWOListMmbr::operator=(float other) {", "PWOMappingMmbr& PWOMappingMmbr::operator=(float other) {", " GrabRef(PWONumber(other));", " _parent.setItem(_key, *this);", " return *this;", "}", "" ] } }, { "old_path": "weave/scxx/PWOMSequence.h", "new_path": "weave/scxx/PWOMSequence.h", "filename": "PWOMSequence.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -24,8 +24,8 @@ public:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n+ PWOListMmbr& operator=(const PWOListMmbr& other);\n PWOListMmbr& operator=(int other);\n- PWOListMmbr& operator=(float other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n@@ -89,28 +89,24 @@ public:\n };\n \n void setItem(int ndx, int val) {\n- //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, double val) {\n- //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, char* val) {\n- //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, std::string val) {\n- //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n@@ -122,20 +118,60 @@ public:\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n- \n+\n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n- };\n+ }\n return *this;\n };\n- PWOList& append(int other);\n- PWOList& append(double other);\n- PWOList& append(char* other);\n- PWOList& append(std::string other);\n+\n+ PWOList& append(int other) {\n+ PyObject* oth = PyInt_FromLong(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ PWOList& append(double other) {\n+ PyObject* oth = PyFloat_FromDouble(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ PWOList& append(char* other) {\n+ PyObject* oth = PyString_FromString(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ PWOList& append(std::string other) {\n+ PyObject* oth = PyString_FromString(other.c_str());\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n \n //PyList_AsTuple\n // problem with this is it's created on the heap\n", "added_lines": 47, "deleted_lines": 11, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n#define PWOMSEQUENCE_H_INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \n\n\nclass PWOList;\n\nclass PWOListMmbr : public PWOBase\n{\n PWOList& _parent;\n int _ndx;\npublic:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n PWOListMmbr& operator=(const PWOListMmbr& other);\n PWOListMmbr& operator=(int other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n};\n\nclass PWOList : public PWOSequence\n{\npublic:\n PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n PWOList(const PWOList& other) : PWOSequence(other) {};\n PWOList(PyObject* obj) : PWOSequence(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOList() {};\n\n virtual PWOList& operator=(const PWOList& other) {\n GrabRef(other);\n return *this;\n };\n PWOList& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool delItem(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool delSlice(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOListMmbr operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return PWOListMmbr(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void setItem(int ndx, PWOBase& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, int val) {\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, double val) {\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n\n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(int other) {\n PyObject* oth = PyInt_FromLong(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(double other) {\n PyObject* oth = PyFloat_FromDouble(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(char* other) {\n PyObject* oth = PyString_FromString(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(std::string other) {\n PyObject* oth = PyString_FromString(other.c_str());\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n PWOList& insert(int ndx, PWOBase& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n PWOList& insert(int ndx, int other);\n PWOList& insert(int ndx, double other);\n PWOList& insert(int ndx, char* other); \n PWOList& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n PWOList& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n};\n\n#endif // PWOMSEQUENCE_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n#define PWOMSEQUENCE_H_INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \n\n\nclass PWOList;\n\nclass PWOListMmbr : public PWOBase\n{\n PWOList& _parent;\n int _ndx;\npublic:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n PWOListMmbr& operator=(int other);\n PWOListMmbr& operator=(float other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n};\n\nclass PWOList : public PWOSequence\n{\npublic:\n PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n PWOList(const PWOList& other) : PWOSequence(other) {};\n PWOList(PyObject* obj) : PWOSequence(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOList() {};\n\n virtual PWOList& operator=(const PWOList& other) {\n GrabRef(other);\n return *this;\n };\n PWOList& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool delItem(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool delSlice(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOListMmbr operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return PWOListMmbr(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void setItem(int ndx, PWOBase& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, int val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, double val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n \n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n };\n return *this;\n };\n PWOList& append(int other);\n PWOList& append(double other);\n PWOList& append(char* other);\n PWOList& append(std::string other);\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n PWOList& insert(int ndx, PWOBase& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n PWOList& insert(int ndx, int other);\n PWOList& insert(int ndx, double other);\n PWOList& insert(int ndx, char* other); \n PWOList& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n PWOList& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n};\n\n#endif // PWOMSEQUENCE_H_INCLUDED_\n", "methods": [ { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 97, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 103, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 109, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 116, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 132, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 143, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 154, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 165, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 202, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 214, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "methods_before": [ { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 120, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 44, "parameters": [ "other" ], "start_line": 127, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 151, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 178, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 132, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 165, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 154, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 143, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 166, "complexity": 42, "token_count": 1096, "diff_parsed": { "added": [ " PWOListMmbr& operator=(const PWOListMmbr& other);", "", " }", "", " PWOList& append(int other) {", " PyObject* oth = PyInt_FromLong(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(double other) {", " PyObject* oth = PyFloat_FromDouble(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(char* other) {", " PyObject* oth = PyString_FromString(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(std::string other) {", " PyObject* oth = PyString_FromString(other.c_str());", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };" ], "deleted": [ " PWOListMmbr& operator=(float other);", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", "", " };", " PWOList& append(int other);", " PWOList& append(double other);", " PWOList& append(char* other);", " PWOList& append(std::string other);" ] } }, { "old_path": "weave/scxx/PWOMapping.h", "new_path": "weave/scxx/PWOMapping.h", "filename": "PWOMapping.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -27,7 +27,6 @@ public:\n };\n PWOMappingMmbr& operator=(const PWOBase& other);\n PWOMappingMmbr& operator=(int other);\n- PWOMappingMmbr& operator=(float other);\n PWOMappingMmbr& operator=(double other);\n PWOMappingMmbr& operator=(const char* other);\n PWOMappingMmbr& operator=(std::string other);\n", "added_lines": 0, "deleted_lines": 1, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMAPPING_H_INCLUDED_)\n#define PWOMAPPING_H_INCLUDED_\n\n#include \"PWOBase.h\"\n#include \"PWOMSequence.h\"\n#include \"PWONumber.h\"\n#include \n\nclass PWOMapping;\n\nclass PWOMappingMmbr : public PWOBase\n{\n PWOMapping& _parent;\n PyObject* _key;\npublic:\n PWOMappingMmbr(PyObject* obj, PWOMapping& parent, PyObject* key)\n : PWOBase(obj), _parent(parent), _key(key)\n {\n Py_XINCREF(_key);\n };\n virtual ~PWOMappingMmbr() {\n Py_XDECREF(_key);\n };\n PWOMappingMmbr& operator=(const PWOBase& other);\n PWOMappingMmbr& operator=(int other);\n PWOMappingMmbr& operator=(double other);\n PWOMappingMmbr& operator=(const char* other);\n PWOMappingMmbr& operator=(std::string other);\n};\n\nclass PWOMapping : public PWOBase\n{\npublic:\n PWOMapping() : PWOBase (PyDict_New()) { LoseRef(_obj); }\n PWOMapping(const PWOMapping& other) : PWOBase(other) {};\n PWOMapping(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOMapping() {};\n\n virtual PWOMapping& operator=(const PWOMapping& other) {\n GrabRef(other);\n return *this;\n };\n PWOMapping& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyMapping_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mapping\");\n }\n };\n\n //PyMapping_GetItemString\n //PyDict_GetItemString\n PWOMappingMmbr operator [] (const char* key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key);\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (std::string key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key.c_str());\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (PyObject* key) {\n PyObject* rslt = PyDict_GetItem(_obj, key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, key);\n };\n\n //PyDict_GetItem\n PWOMappingMmbr operator [] (int key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (float key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (double key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyMapping_HasKey\n bool hasKey(PyObject* key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n //PyMapping_HasKeyString\n bool hasKey(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n //PyMapping_Length\n //PyDict_Size\n int len() const {\n return PyMapping_Length(_obj);\n };\n //PyMapping_SetItemString\n //PyDict_SetItemString\n void setItem(const char* key, PyObject* val) {\n int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n //PyDict_SetItem\n void setItem(PyObject* key, PyObject* val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key must be hashable\");\n };\n //PyDict_Clear\n void clear() {\n PyDict_Clear(_obj);\n };\n //PyDict_DelItem\n void delItem(PyObject* key) {\n int rslt = PyMapping_DelItem(_obj, key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_DelItemString\n void delItem(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_Items\n PWOList items() const {\n PyObject* rslt = PyMapping_Items(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get items\");\n return LoseRef(rslt);\n };\n //PyDict_Keys\n PWOList keys() const {\n PyObject* rslt = PyMapping_Keys(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get keys\");\n return LoseRef(rslt);\n };\n //PyDict_New - default constructor\n //PyDict_Next\n //PyDict_Values\n PWOList values() const {\n PyObject* rslt = PyMapping_Values(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get values\");\n return LoseRef(rslt);\n };\n};\n\n#endif // PWOMAPPING_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMAPPING_H_INCLUDED_)\n#define PWOMAPPING_H_INCLUDED_\n\n#include \"PWOBase.h\"\n#include \"PWOMSequence.h\"\n#include \"PWONumber.h\"\n#include \n\nclass PWOMapping;\n\nclass PWOMappingMmbr : public PWOBase\n{\n PWOMapping& _parent;\n PyObject* _key;\npublic:\n PWOMappingMmbr(PyObject* obj, PWOMapping& parent, PyObject* key)\n : PWOBase(obj), _parent(parent), _key(key)\n {\n Py_XINCREF(_key);\n };\n virtual ~PWOMappingMmbr() {\n Py_XDECREF(_key);\n };\n PWOMappingMmbr& operator=(const PWOBase& other);\n PWOMappingMmbr& operator=(int other);\n PWOMappingMmbr& operator=(float other);\n PWOMappingMmbr& operator=(double other);\n PWOMappingMmbr& operator=(const char* other);\n PWOMappingMmbr& operator=(std::string other);\n};\n\nclass PWOMapping : public PWOBase\n{\npublic:\n PWOMapping() : PWOBase (PyDict_New()) { LoseRef(_obj); }\n PWOMapping(const PWOMapping& other) : PWOBase(other) {};\n PWOMapping(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOMapping() {};\n\n virtual PWOMapping& operator=(const PWOMapping& other) {\n GrabRef(other);\n return *this;\n };\n PWOMapping& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyMapping_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mapping\");\n }\n };\n\n //PyMapping_GetItemString\n //PyDict_GetItemString\n PWOMappingMmbr operator [] (const char* key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key);\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (std::string key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key.c_str());\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (PyObject* key) {\n PyObject* rslt = PyDict_GetItem(_obj, key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, key);\n };\n\n //PyDict_GetItem\n PWOMappingMmbr operator [] (int key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (float key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (double key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyMapping_HasKey\n bool hasKey(PyObject* key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n //PyMapping_HasKeyString\n bool hasKey(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n //PyMapping_Length\n //PyDict_Size\n int len() const {\n return PyMapping_Length(_obj);\n };\n //PyMapping_SetItemString\n //PyDict_SetItemString\n void setItem(const char* key, PyObject* val) {\n int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n //PyDict_SetItem\n void setItem(PyObject* key, PyObject* val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key must be hashable\");\n };\n //PyDict_Clear\n void clear() {\n PyDict_Clear(_obj);\n };\n //PyDict_DelItem\n void delItem(PyObject* key) {\n int rslt = PyMapping_DelItem(_obj, key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_DelItemString\n void delItem(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_Items\n PWOList items() const {\n PyObject* rslt = PyMapping_Items(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get items\");\n return LoseRef(rslt);\n };\n //PyDict_Keys\n PWOList keys() const {\n PyObject* rslt = PyMapping_Keys(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get keys\");\n return LoseRef(rslt);\n };\n //PyDict_New - default constructor\n //PyDict_Next\n //PyDict_Values\n PWOList values() const {\n PyObject* rslt = PyMapping_Values(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get values\");\n return LoseRef(rslt);\n };\n};\n\n#endif // PWOMAPPING_H_INCLUDED_\n", "methods": [ { "name": "PWOMappingMmbr::PWOMappingMmbr", "long_name": "PWOMappingMmbr::PWOMappingMmbr( PyObject * obj , PWOMapping & parent , PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMappingMmbr::~PWOMappingMmbr", "long_name": "PWOMappingMmbr::~PWOMappingMmbr()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( PyObject * obj)", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::~PWOMapping", "long_name": "PWOMapping::~PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 43, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOBase & other)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::_violentTypeCheck", "long_name": "PWOMapping::_violentTypeCheck()", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 54, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( const char * key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 63, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( std :: string key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( PyObject * key)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( int key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 88, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( float key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 97, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( double key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( PyObject * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( const char * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::len", "long_name": "PWOMapping::len() const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( const char * key , PyObject * val)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( PyObject * key , PyObject * val) const", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 134, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::clear", "long_name": "PWOMapping::clear()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( const char * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::items", "long_name": "PWOMapping::items() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::keys", "long_name": "PWOMapping::keys() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 163, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::values", "long_name": "PWOMapping::values() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "methods_before": [ { "name": "PWOMappingMmbr::PWOMappingMmbr", "long_name": "PWOMappingMmbr::PWOMappingMmbr( PyObject * obj , PWOMapping & parent , PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMappingMmbr::~PWOMappingMmbr", "long_name": "PWOMappingMmbr::~PWOMappingMmbr()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 40, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( PyObject * obj)", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::~PWOMapping", "long_name": "PWOMapping::~PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOBase & other)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::_violentTypeCheck", "long_name": "PWOMapping::_violentTypeCheck()", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( const char * key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 64, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( std :: string key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 72, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( PyObject * key)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 81, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( int key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 89, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( float key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 98, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( double key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 106, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( PyObject * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( const char * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::len", "long_name": "PWOMapping::len() const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( const char * key , PyObject * val)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( PyObject * key , PyObject * val) const", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::clear", "long_name": "PWOMapping::clear()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 141, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( const char * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::items", "long_name": "PWOMapping::items() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 157, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::keys", "long_name": "PWOMapping::keys() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 164, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::values", "long_name": "PWOMapping::values() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [], "nloc": 132, "complexity": 36, "token_count": 890, "diff_parsed": { "added": [], "deleted": [ " PWOMappingMmbr& operator=(float other);" ] } }, { "old_path": null, "new_path": "weave/scxx/callable.h", "filename": "callable.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,46 @@\n+/******************************************** \n+ copyright 2000 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+ \n+ modified for weave by eric jones\n+*********************************************/\n+\n+#if !defined(CALLABLE_H_INCLUDED_)\n+#define CALLABLE_H_INCLUDED_\n+\n+#include \"object.h\"\n+#include \"tuple.h\"\n+#include \"dict.h\"\n+\n+namespace py {\n+ \n+class callable : public object\n+{\n+public:\n+ callable() : object() {};\n+ callable(PyObject *obj) : object(obj) {\n+ _violentTypeCheck();\n+ };\n+ virtual ~callable() {};\n+ virtual callable& operator=(const callable& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ callable& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!is_callable()) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a callable object\");\n+ }\n+ };\n+ object call() const;\n+ object call(tuple& args) const;\n+ object call(tuple& args, dict& kws) const;\n+};\n+\n+} // namespace py\n+#endif\n", "added_lines": 46, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 2000 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(CALLABLE_H_INCLUDED_)\n#define CALLABLE_H_INCLUDED_\n\n#include \"object.h\"\n#include \"tuple.h\"\n#include \"dict.h\"\n\nnamespace py {\n \nclass callable : public object\n{\npublic:\n callable() : object() {};\n callable(PyObject *obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~callable() {};\n virtual callable& operator=(const callable& other) {\n GrabRef(other);\n return *this;\n };\n callable& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!is_callable()) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a callable object\");\n }\n };\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n};\n\n} // namespace py\n#endif\n", "source_code_before": null, "methods": [ { "name": "py::callable::callable", "long_name": "py::callable::callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::callable", "long_name": "py::callable::callable( PyObject * obj)", "filename": "callable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::callable::~callable", "long_name": "py::callable::~callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const callable & other)", "filename": "callable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const object & other)", "filename": "callable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 29, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::callable::_violentTypeCheck", "long_name": "py::callable::_violentTypeCheck()", "filename": "callable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::callable::callable", "long_name": "py::callable::callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const callable & other)", "filename": "callable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::callable::~callable", "long_name": "py::callable::~callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::_violentTypeCheck", "long_name": "py::callable::_violentTypeCheck()", "filename": "callable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::callable::callable", "long_name": "py::callable::callable( PyObject * obj)", "filename": "callable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const object & other)", "filename": "callable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 29, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 32, "complexity": 7, "token_count": 161, "diff_parsed": { "added": [ "/********************************************", " copyright 2000 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified for weave by eric jones", "*********************************************/", "", "#if !defined(CALLABLE_H_INCLUDED_)", "#define CALLABLE_H_INCLUDED_", "", "#include \"object.h\"", "#include \"tuple.h\"", "#include \"dict.h\"", "", "namespace py {", "", "class callable : public object", "{", "public:", " callable() : object() {};", " callable(PyObject *obj) : object(obj) {", " _violentTypeCheck();", " };", " virtual ~callable() {};", " virtual callable& operator=(const callable& other) {", " GrabRef(other);", " return *this;", " };", " callable& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!is_callable()) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a callable object\");", " }", " };", " object call() const;", " object call(tuple& args) const;", " object call(tuple& args, dict& kws) const;", "};", "", "} // namespace py", "#endif" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/dict.h", "filename": "dict.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,182 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+ \n+ modified for weave by eric jones\n+*********************************************/\n+\n+#if !defined(DICT_H_INCLUDED_)\n+#define DICT_H_INCLUDED_\n+\n+#include \"object.h\"\n+#include \"number.h\"\n+#include \"list.h\"\n+#include \"str.h\"\n+#include \n+\n+namespace py {\n+\n+class dict;\n+ \n+class dict_member : public object\n+{\n+ dict& _parent;\n+ PyObject* _key;\n+public:\n+ dict_member(PyObject* obj, dict& parent, PyObject* key)\n+ : object(obj), _parent(parent), _key(key)\n+ {\n+ Py_XINCREF(_key);\n+ };\n+ virtual ~dict_member() {\n+ Py_XDECREF(_key);\n+ };\n+ dict_member& operator=(const object& other);\n+ dict_member& operator=(int other);\n+ dict_member& operator=(double other);\n+ dict_member& operator=(const char* other);\n+ dict_member& operator=(std::string other);\n+};\n+\n+class dict : public object\n+{\n+public:\n+ dict() : object (PyDict_New()) { LoseRef(_obj); }\n+ dict(const dict& other) : object(other) {};\n+ dict(PyObject* obj) : object(obj) {\n+ _violentTypeCheck();\n+ };\n+ virtual ~dict() {};\n+\n+ virtual dict& operator=(const dict& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ dict& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PyMapping_Check(_obj)) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a mapping\");\n+ }\n+ };\n+\n+ //PyMapping_GetItemString\n+ //PyDict_GetItemString\n+ dict_member operator [] (const char* key) {\n+ PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n+ if (rslt==0)\n+ PyErr_Clear();\n+ // ?? why do I need py:: here?\n+ str _key(key);\n+ return dict_member(rslt, *this, _key);\n+ };\n+\n+ dict_member operator [] (std::string key) {\n+ PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n+ if (rslt==0)\n+ PyErr_Clear();\n+ str _key(key.c_str());\n+ return dict_member(rslt, *this, _key);\n+ };\n+\n+ //PyDict_GetItem\n+ dict_member operator [] (PyObject* key) {\n+ PyObject* rslt = PyDict_GetItem(_obj, key);\n+ //if (rslt==0)\n+ // Fail(PyExc_KeyError, \"Key not found\");\n+ return dict_member(rslt, *this, key);\n+ };\n+\n+ //PyDict_GetItem\n+ dict_member operator [] (int key) {\n+ number _key = number(key);\n+ PyObject* rslt = PyDict_GetItem(_obj, _key);\n+ //if (rslt==0)\n+ // Fail(PyExc_KeyError, \"Key not found\");\n+ return dict_member(rslt, *this, _key);\n+ };\n+ \n+ dict_member operator [] (double key) {\n+ number _key = number(key);\n+ PyObject* rslt = PyDict_GetItem(_obj, _key);\n+ //if (rslt==0)\n+ // Fail(PyExc_KeyError, \"Key not found\");\n+ return dict_member(rslt, *this, _key);\n+ };\n+ \n+ //PyMapping_HasKey\n+ bool has_key(PyObject* key) const {\n+ return PyMapping_HasKey(_obj, key)==1;\n+ };\n+ //PyMapping_HasKeyString\n+ bool has_key(const char* key) const {\n+ return PyMapping_HasKeyString(_obj, (char*) key)==1;\n+ };\n+ //PyMapping_Length\n+ //PyDict_Size\n+ int len() const {\n+ return PyMapping_Length(_obj);\n+ } \n+ int length() const {\n+ return PyMapping_Length(_obj);\n+ };\n+ //PyMapping_SetItemString\n+ //PyDict_SetItemString\n+ void set_item(const char* key, PyObject* val) {\n+ int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n+ if (rslt==-1)\n+ Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n+ };\n+ //PyDict_SetItem\n+ void set_item(PyObject* key, PyObject* val) const {\n+ int rslt = PyDict_SetItem(_obj, key, val);\n+ if (rslt==-1)\n+ Fail(PyExc_KeyError, \"Key must be hashable\");\n+ };\n+ //PyDict_Clear\n+ void clear() {\n+ PyDict_Clear(_obj);\n+ };\n+ //PyDict_DelItem\n+ void del(PyObject* key) {\n+ int rslt = PyMapping_DelItem(_obj, key);\n+ if (rslt==-1)\n+ Fail(PyExc_KeyError, \"Key not found\");\n+ };\n+ //PyDict_DelItemString\n+ void del(const char* key) {\n+ int rslt = PyDict_DelItemString(_obj, (char*) key);\n+ if (rslt==-1)\n+ Fail(PyExc_KeyError, \"Key not found\");\n+ };\n+ //PyDict_Items\n+ list items() const {\n+ PyObject* rslt = PyMapping_Items(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_RuntimeError, \"Failed to get items\");\n+ return LoseRef(rslt);\n+ };\n+ //PyDict_Keys\n+ list keys() const {\n+ PyObject* rslt = PyMapping_Keys(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_RuntimeError, \"Failed to get keys\");\n+ return LoseRef(rslt);\n+ };\n+ //PyDict_New - default constructor\n+ //PyDict_Next\n+ //PyDict_Values\n+ list values() const {\n+ PyObject* rslt = PyMapping_Values(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_RuntimeError, \"Failed to get values\");\n+ return LoseRef(rslt);\n+ };\n+};\n+\n+} // namespace\n+#endif // DICT_H_INCLUDED_\n", "added_lines": 182, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n\n#include \"object.h\"\n#include \"number.h\"\n#include \"list.h\"\n#include \"str.h\"\n#include \n\nnamespace py {\n\nclass dict;\n \nclass dict_member : public object\n{\n dict& _parent;\n PyObject* _key;\npublic:\n dict_member(PyObject* obj, dict& parent, PyObject* key)\n : object(obj), _parent(parent), _key(key)\n {\n Py_XINCREF(_key);\n };\n virtual ~dict_member() {\n Py_XDECREF(_key);\n };\n dict_member& operator=(const object& other);\n dict_member& operator=(int other);\n dict_member& operator=(double other);\n dict_member& operator=(const char* other);\n dict_member& operator=(std::string other);\n};\n\nclass dict : public object\n{\npublic:\n dict() : object (PyDict_New()) { LoseRef(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~dict() {};\n\n virtual dict& operator=(const dict& other) {\n GrabRef(other);\n return *this;\n };\n dict& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyMapping_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mapping\");\n }\n };\n\n //PyMapping_GetItemString\n //PyDict_GetItemString\n dict_member operator [] (const char* key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n if (rslt==0)\n PyErr_Clear();\n // ?? why do I need py:: here?\n str _key(key);\n return dict_member(rslt, *this, _key);\n };\n\n dict_member operator [] (std::string key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n if (rslt==0)\n PyErr_Clear();\n str _key(key.c_str());\n return dict_member(rslt, *this, _key);\n };\n\n //PyDict_GetItem\n dict_member operator [] (PyObject* key) {\n PyObject* rslt = PyDict_GetItem(_obj, key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, key);\n };\n\n //PyDict_GetItem\n dict_member operator [] (int key) {\n number _key = number(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, _key);\n };\n \n dict_member operator [] (double key) {\n number _key = number(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, _key);\n };\n \n //PyMapping_HasKey\n bool has_key(PyObject* key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n //PyMapping_HasKeyString\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n //PyMapping_Length\n //PyDict_Size\n int len() const {\n return PyMapping_Length(_obj);\n } \n int length() const {\n return PyMapping_Length(_obj);\n };\n //PyMapping_SetItemString\n //PyDict_SetItemString\n void set_item(const char* key, PyObject* val) {\n int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n //PyDict_SetItem\n void set_item(PyObject* key, PyObject* val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key must be hashable\");\n };\n //PyDict_Clear\n void clear() {\n PyDict_Clear(_obj);\n };\n //PyDict_DelItem\n void del(PyObject* key) {\n int rslt = PyMapping_DelItem(_obj, key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_DelItemString\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_Items\n list items() const {\n PyObject* rslt = PyMapping_Items(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get items\");\n return LoseRef(rslt);\n };\n //PyDict_Keys\n list keys() const {\n PyObject* rslt = PyMapping_Keys(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get keys\");\n return LoseRef(rslt);\n };\n //PyDict_New - default constructor\n //PyDict_Next\n //PyDict_Values\n list values() const {\n PyObject* rslt = PyMapping_Values(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get values\");\n return LoseRef(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::dict_member::dict_member", "long_name": "py::dict_member::dict_member( PyObject * obj , dict & parent , PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict_member::~dict_member", "long_name": "py::dict_member::~dict_member()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 45, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 46, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 49, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 51, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( std :: string key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 78, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( PyObject * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 95, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 103, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( PyObject * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , PyObject * val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( PyObject * key , PyObject * val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 141, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 157, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 164, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 95, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict_member::~dict_member", "long_name": "py::dict_member::~dict_member()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 45, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 103, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 141, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 46, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 164, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( PyObject * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( PyObject * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( std :: string key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 78, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , PyObject * val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( PyObject * key , PyObject * val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 49, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict_member::dict_member", "long_name": "py::dict_member::dict_member( PyObject * obj , dict & parent , PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 51, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 157, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 133, "complexity": 36, "token_count": 868, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified for weave by eric jones", "*********************************************/", "", "#if !defined(DICT_H_INCLUDED_)", "#define DICT_H_INCLUDED_", "", "#include \"object.h\"", "#include \"number.h\"", "#include \"list.h\"", "#include \"str.h\"", "#include ", "", "namespace py {", "", "class dict;", "", "class dict_member : public object", "{", " dict& _parent;", " PyObject* _key;", "public:", " dict_member(PyObject* obj, dict& parent, PyObject* key)", " : object(obj), _parent(parent), _key(key)", " {", " Py_XINCREF(_key);", " };", " virtual ~dict_member() {", " Py_XDECREF(_key);", " };", " dict_member& operator=(const object& other);", " dict_member& operator=(int other);", " dict_member& operator=(double other);", " dict_member& operator=(const char* other);", " dict_member& operator=(std::string other);", "};", "", "class dict : public object", "{", "public:", " dict() : object (PyDict_New()) { LoseRef(_obj); }", " dict(const dict& other) : object(other) {};", " dict(PyObject* obj) : object(obj) {", " _violentTypeCheck();", " };", " virtual ~dict() {};", "", " virtual dict& operator=(const dict& other) {", " GrabRef(other);", " return *this;", " };", " dict& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyMapping_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mapping\");", " }", " };", "", " //PyMapping_GetItemString", " //PyDict_GetItemString", " dict_member operator [] (const char* key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);", " if (rslt==0)", " PyErr_Clear();", " // ?? why do I need py:: here?", " str _key(key);", " return dict_member(rslt, *this, _key);", " };", "", " dict_member operator [] (std::string key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());", " if (rslt==0)", " PyErr_Clear();", " str _key(key.c_str());", " return dict_member(rslt, *this, _key);", " };", "", " //PyDict_GetItem", " dict_member operator [] (PyObject* key) {", " PyObject* rslt = PyDict_GetItem(_obj, key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, key);", " };", "", " //PyDict_GetItem", " dict_member operator [] (int key) {", " number _key = number(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, _key);", " };", "", " dict_member operator [] (double key) {", " number _key = number(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, _key);", " };", "", " //PyMapping_HasKey", " bool has_key(PyObject* key) const {", " return PyMapping_HasKey(_obj, key)==1;", " };", " //PyMapping_HasKeyString", " bool has_key(const char* key) const {", " return PyMapping_HasKeyString(_obj, (char*) key)==1;", " };", " //PyMapping_Length", " //PyDict_Size", " int len() const {", " return PyMapping_Length(_obj);", " }", " int length() const {", " return PyMapping_Length(_obj);", " };", " //PyMapping_SetItemString", " //PyDict_SetItemString", " void set_item(const char* key, PyObject* val) {", " int rslt = PyMapping_SetItemString(_obj, (char*) key, val);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"Cannot add key / value\");", " };", " //PyDict_SetItem", " void set_item(PyObject* key, PyObject* val) const {", " int rslt = PyDict_SetItem(_obj, key, val);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key must be hashable\");", " };", " //PyDict_Clear", " void clear() {", " PyDict_Clear(_obj);", " };", " //PyDict_DelItem", " void del(PyObject* key) {", " int rslt = PyMapping_DelItem(_obj, key);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key not found\");", " };", " //PyDict_DelItemString", " void del(const char* key) {", " int rslt = PyDict_DelItemString(_obj, (char*) key);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key not found\");", " };", " //PyDict_Items", " list items() const {", " PyObject* rslt = PyMapping_Items(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get items\");", " return LoseRef(rslt);", " };", " //PyDict_Keys", " list keys() const {", " PyObject* rslt = PyMapping_Keys(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get keys\");", " return LoseRef(rslt);", " };", " //PyDict_New - default constructor", " //PyDict_Next", " //PyDict_Values", " list values() const {", " PyObject* rslt = PyMapping_Values(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get values\");", " return LoseRef(rslt);", " };", "};", "", "} // namespace", "#endif // DICT_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/list.h", "filename": "list.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,228 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+\n+ modified for weave by eric jones\n+*********************************************/\n+#if !defined(LIST_H_INCLUDED_)\n+#define LIST_H_INCLUDED_\n+\n+// ej: not sure what this is about, but we'll leave it.\n+#if _MSC_VER >= 1000\n+#pragma once\n+#endif // _MSC_VER >= 1000\n+\n+#include \"object.h\"\n+#include \"sequence.h\"\n+#include \n+\n+namespace py {\n+ \n+class list_member : public object\n+{\n+ list& _parent;\n+ int _ndx;\n+public:\n+ list_member(PyObject* obj, list& parent, int ndx);\n+ virtual ~list_member() {};\n+ list_member& operator=(const object& other);\n+ list_member& operator=(const list_member& other);\n+ list_member& operator=(int other);\n+ list_member& operator=(double other);\n+ list_member& operator=(const char* other);\n+ list_member& operator=(std::string other);\n+};\n+\n+class list : public sequence\n+{\n+public:\n+ list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }\n+ list(const list& other) : sequence(other) {};\n+ list(PyObject* obj) : sequence(obj) {\n+ _violentTypeCheck();\n+ };\n+ virtual ~list() {};\n+\n+ virtual list& operator=(const list& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ list& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a mutable sequence\");\n+ }\n+ };\n+ //PySequence_DelItem ##lists\n+ bool del(int i) {\n+ int rslt = PySequence_DelItem(_obj, i);\n+ if (rslt == -1)\n+ Fail(PyExc_RuntimeError, \"cannot delete item\");\n+ return true;\n+ };\n+ //PySequence_DelSlice ##lists\n+ bool del(int lo, int hi) {\n+ int rslt = PySequence_DelSlice(_obj, lo, hi);\n+ if (rslt == -1)\n+ Fail(PyExc_RuntimeError, \"cannot delete slice\");\n+ return true;\n+ };\n+ //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object\n+ list_member operator [] (int i) { // can't be virtual\n+ //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n+ PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n+ //Py_XINCREF(o);\n+ //if (o == 0)\n+ // Fail(PyExc_IndexError, \"index out of range\");\n+ return list_member(o, *this, i); // this increfs\n+ };\n+ //PySequence_SetItem ##Lists\n+ void set_item(int ndx, object& val) {\n+ //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n+ int rslt = PyList_SetItem(_obj, ndx, val);\n+ val.disown(); //when using PyList_SetItem, he steals my reference\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, int val) {\n+ int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+ \n+ void set_item(int ndx, double val) {\n+ int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, char* val) {\n+ int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, std::string val) {\n+ int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ //PySequence_SetSlice ##Lists\n+ void setSlice(int lo, int hi, const sequence& slice) {\n+ int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n+ if (rslt==-1)\n+ Fail(PyExc_RuntimeError, \"Error setting slice\");\n+ };\n+\n+ //PyList_Append\n+ list& append(const object& other) {\n+ int rslt = PyList_Append(_obj, other);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ list& append(int other) {\n+ PyObject* oth = PyInt_FromLong(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ list& append(double other) {\n+ PyObject* oth = PyFloat_FromDouble(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ list& append(char* other) {\n+ PyObject* oth = PyString_FromString(other);\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ list& append(std::string other) {\n+ PyObject* oth = PyString_FromString(other.c_str());\n+ int rslt = PyList_Append(_obj, oth); \n+ Py_XDECREF(oth);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error appending\");\n+ }\n+ return *this;\n+ };\n+\n+ //PyList_AsTuple\n+ // problem with this is it's created on the heap\n+ //virtual PWOTuple& asTuple() const {\n+ // PyObject* rslt = PyList_AsTuple(_obj);\n+ // PWOTuple rtrn = new PWOTuple(rslt);\n+ // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n+ // return *rtrn;\n+ //};\n+ //PyList_GetItem - inherited OK\n+ //PyList_GetSlice - inherited OK\n+ //PyList_Insert\n+ list& insert(int ndx, object& other) {\n+ int rslt = PyList_Insert(_obj, ndx, other);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error inserting\");\n+ };\n+ return *this;\n+ };\n+ list& insert(int ndx, int other);\n+ list& insert(int ndx, double other);\n+ list& insert(int ndx, char* other); \n+ list& insert(int ndx, std::string other);\n+\n+ //PyList_New\n+ //PyList_Reverse\n+ list& reverse() {\n+ int rslt = PyList_Reverse(_obj);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error reversing\");\n+ };\n+ return *this; //HA HA - Guido can't stop me!!!\n+ };\n+ //PyList_SetItem - using abstract\n+ //PyList_SetSlice - using abstract\n+ //PyList_Size - inherited OK\n+ //PyList_Sort\n+ list& sort() {\n+ int rslt = PyList_Sort(_obj);\n+ if (rslt==-1) {\n+ PyErr_Clear(); //Python sets one \n+ Fail(PyExc_RuntimeError, \"Error sorting\");\n+ };\n+ return *this; //HA HA - Guido can't stop me!!!\n+ };\n+}; // class list\n+\n+} // namespace py\n+\n+#endif // LIST_H_INCLUDED_\n", "added_lines": 228, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(LIST_H_INCLUDED_)\n#define LIST_H_INCLUDED_\n\n// ej: not sure what this is about, but we'll leave it.\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"object.h\"\n#include \"sequence.h\"\n#include \n\nnamespace py {\n \nclass list_member : public object\n{\n list& _parent;\n int _ndx;\npublic:\n list_member(PyObject* obj, list& parent, int ndx);\n virtual ~list_member() {};\n list_member& operator=(const object& other);\n list_member& operator=(const list_member& other);\n list_member& operator=(int other);\n list_member& operator=(double other);\n list_member& operator=(const char* other);\n list_member& operator=(std::string other);\n};\n\nclass list : public sequence\n{\npublic:\n list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }\n list(const list& other) : sequence(other) {};\n list(PyObject* obj) : sequence(obj) {\n _violentTypeCheck();\n };\n virtual ~list() {};\n\n virtual list& operator=(const list& other) {\n GrabRef(other);\n return *this;\n };\n list& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool del(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool del(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object\n list_member operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return list_member(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void set_item(int ndx, object& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disown(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, int val) {\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void set_item(int ndx, double val) {\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, char* val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, std::string val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const sequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n\n //PyList_Append\n list& append(const object& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(int other) {\n PyObject* oth = PyInt_FromLong(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(double other) {\n PyObject* oth = PyFloat_FromDouble(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(char* other) {\n PyObject* oth = PyString_FromString(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(std::string other) {\n PyObject* oth = PyString_FromString(other.c_str());\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n list& insert(int ndx, object& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n list& insert(int ndx, int other);\n list& insert(int ndx, double other);\n list& insert(int ndx, char* other); \n list& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n list& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n list& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n}; // class list\n\n} // namespace py\n\n#endif // LIST_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::list_member::~list_member", "long_name": "py::list_member::~list_member()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( int size = 0)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( const list & other)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 40, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( PyObject * obj)", "filename": "list.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::list::~list", "long_name": "py::list::~list()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const list & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const object & other)", "filename": "list.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::_violentTypeCheck", "long_name": "py::list::_violentTypeCheck()", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int i)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int lo , int hi)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::operator [ ]", "long_name": "py::list::operator [ ]( int i)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , object & val)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 85, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , int val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 93, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , double val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 99, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , char * val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , std :: string val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::setSlice", "long_name": "py::list::setSlice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( int other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 134, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( double other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 145, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( char * other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 156, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( std :: string other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 167, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::insert", "long_name": "py::list::insert( int ndx , object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::reverse", "long_name": "py::list::reverse()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 204, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::sort", "long_name": "py::list::sort()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 216, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::list::del", "long_name": "py::list::del( int lo , int hi)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list_member::~list_member", "long_name": "py::list_member::~list_member()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , char * val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( const list & other)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 40, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , double val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 99, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int i)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const list & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , object & val)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 85, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( int size = 0)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::insert", "long_name": "py::list::insert( int ndx , object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::reverse", "long_name": "py::list::reverse()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 204, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::~list", "long_name": "py::list::~list()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::_violentTypeCheck", "long_name": "py::list::_violentTypeCheck()", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( int other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 134, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( char * other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 156, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , std :: string val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::setSlice", "long_name": "py::list::setSlice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::sort", "long_name": "py::list::sort()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 216, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( double other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 145, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const object & other)", "filename": "list.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , int val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 93, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( PyObject * obj)", "filename": "list.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( std :: string other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 167, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::operator [ ]", "long_name": "py::list::operator [ ]( int i)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "nloc": 167, "complexity": 42, "token_count": 1097, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified for weave by eric jones", "*********************************************/", "#if !defined(LIST_H_INCLUDED_)", "#define LIST_H_INCLUDED_", "", "// ej: not sure what this is about, but we'll leave it.", "#if _MSC_VER >= 1000", "#pragma once", "#endif // _MSC_VER >= 1000", "", "#include \"object.h\"", "#include \"sequence.h\"", "#include ", "", "namespace py {", "", "class list_member : public object", "{", " list& _parent;", " int _ndx;", "public:", " list_member(PyObject* obj, list& parent, int ndx);", " virtual ~list_member() {};", " list_member& operator=(const object& other);", " list_member& operator=(const list_member& other);", " list_member& operator=(int other);", " list_member& operator=(double other);", " list_member& operator=(const char* other);", " list_member& operator=(std::string other);", "};", "", "class list : public sequence", "{", "public:", " list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }", " list(const list& other) : sequence(other) {};", " list(PyObject* obj) : sequence(obj) {", " _violentTypeCheck();", " };", " virtual ~list() {};", "", " virtual list& operator=(const list& other) {", " GrabRef(other);", " return *this;", " };", " list& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mutable sequence\");", " }", " };", " //PySequence_DelItem ##lists", " bool del(int i) {", " int rslt = PySequence_DelItem(_obj, i);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"cannot delete item\");", " return true;", " };", " //PySequence_DelSlice ##lists", " bool del(int lo, int hi) {", " int rslt = PySequence_DelSlice(_obj, lo, hi);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"cannot delete slice\");", " return true;", " };", " //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object", " list_member operator [] (int i) { // can't be virtual", " //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid", " PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount", " //Py_XINCREF(o);", " //if (o == 0)", " // Fail(PyExc_IndexError, \"index out of range\");", " return list_member(o, *this, i); // this increfs", " };", " //PySequence_SetItem ##Lists", " void set_item(int ndx, object& val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, val);", " val.disown(); //when using PyList_SetItem, he steals my reference", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, int val) {", " int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, double val) {", " int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, char* val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, std::string val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " //PySequence_SetSlice ##Lists", " void setSlice(int lo, int hi, const sequence& slice) {", " int rslt = PySequence_SetSlice(_obj, lo, hi, slice);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"Error setting slice\");", " };", "", " //PyList_Append", " list& append(const object& other) {", " int rslt = PyList_Append(_obj, other);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " list& append(int other) {", " PyObject* oth = PyInt_FromLong(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " list& append(double other) {", " PyObject* oth = PyFloat_FromDouble(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " list& append(char* other) {", " PyObject* oth = PyString_FromString(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " list& append(std::string other) {", " PyObject* oth = PyString_FromString(other.c_str());", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " //PyList_AsTuple", " // problem with this is it's created on the heap", " //virtual PWOTuple& asTuple() const {", " // PyObject* rslt = PyList_AsTuple(_obj);", " // PWOTuple rtrn = new PWOTuple(rslt);", " // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed", " // return *rtrn;", " //};", " //PyList_GetItem - inherited OK", " //PyList_GetSlice - inherited OK", " //PyList_Insert", " list& insert(int ndx, object& other) {", " int rslt = PyList_Insert(_obj, ndx, other);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error inserting\");", " };", " return *this;", " };", " list& insert(int ndx, int other);", " list& insert(int ndx, double other);", " list& insert(int ndx, char* other);", " list& insert(int ndx, std::string other);", "", " //PyList_New", " //PyList_Reverse", " list& reverse() {", " int rslt = PyList_Reverse(_obj);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error reversing\");", " };", " return *this; //HA HA - Guido can't stop me!!!", " };", " //PyList_SetItem - using abstract", " //PyList_SetSlice - using abstract", " //PyList_Size - inherited OK", " //PyList_Sort", " list& sort() {", " int rslt = PyList_Sort(_obj);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error sorting\");", " };", " return *this; //HA HA - Guido can't stop me!!!", " };", "}; // class list", "", "} // namespace py", "", "#endif // LIST_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/notes.txt", "filename": "notes.txt", "extension": "txt", "change_type": "ADD", "diff": "@@ -0,0 +1,161 @@\n+base package\n+ scipy_base\n+ scipy_distutils\n+ scipy_test\n+ gui_thread\n+\n+scipy\n+weave\n+chaco\n+ \n+weave\n+\n+Proposed changes:\n+\n+* all classes moved to py:: namespace\n+* made tuples mutable with indexing notation. (handy in weave)\n+* converted camel case names (setItem -> set_item)\n+\n+\n+* change class names to reflect boost like names and put each \n+ exposed class in its own header file.\n+ PWOBase -> py::object -- object.h \n+ PWOList -> py::list -- list.h \n+ PWOTuple -> py::tuple -- tuple.h \n+ PWOMapping -> py::dict -- dict.h \n+ PWOCallable -> py::callable -- callable.h \n+ PWOString -> py::str -- str.h \n+ PWONumber -> py::number -- number.h \n+ \n+ py::object public methods:\n+ int print(FILE *f, int flags) const DONE\n+\n+ bool hasattr(const char* nm) const DONE\n+\n+ py::object_attr attr(const char* nm) const\n+ py::object_attr attr(const py::object& nm) const\n+\n+ ??\n+ int set_attr(const char* nm, py::object& val)\n+ int set_attr(PyObject* nm, py::object& val)\n+\n+ int del(const char* nm)\n+ int del(const py::object& nm)\n+ \n+ int cmp(const py::object& other) const\n+\n+ bool operator == (const py::object& other) const \n+ bool operator != (const py::object& other) const \n+ bool operator > (const py::object& other) const \n+ bool operator < (const py::object& other) const\n+ bool operator >= (const py::object& other) const\n+ bool operator <= (const py::object& other) const \n+ \n+ PyObject* repr() const\n+ /*PyObject* str() const*/ // conflicts with class named str\n+ PyObject* type() const\n+ \n+ int hash() const\n+ bool is_true() const\n+ bool is_callable() const\n+ \n+ PyObject* disown() \n+\n+\n+ py::sequence public methods:\n+ PWOSequence operator+(const PWOSequence& rhs) const\n+ //count\n+ int count(const py::object& value) const\n+ int count(int value) const;\n+ int count(double value) const; \n+ int count(char* value) const;\n+ int count(std::string value) const;\n+ \n+ py::object operator [] (int i) const\n+ py::sequence get_slice(int lo, int hi) const\n+ \n+ bool in(const py::object& value) const\n+ bool in(int value); \n+ bool in(double value);\n+ bool in(char* value);\n+ bool in(std::string value);\n+ \n+ int index(const py::object& value) const\n+ int index(int value) const;\n+ int index(double value) const;\n+ int index(char* value) const;\n+ int index(std::string value) const; \n+ \n+ int len() const\n+ int length() const // compatible with std::string\n+\n+ py::sequence operator * (int count) const //repeat\n+\n+ class py::tuple\n+ void set_item(int ndx, py::object& val)\n+ void set_item(int ndx, int val)\n+ void set_item(int ndx, double val)\n+ void set_item(int ndx, char* val)\n+ void set_item(int ndx, std::string val)\n+ \n+ // make tuples mutable like lists\n+ // much easier to set up call lists, etc.\n+ py::tuple_member operator [] (int i)\n+ \n+ class py::list\n+\n+ bool del(int i)\n+ bool del(int lo, int hi)\n+\n+ py::list_member operator [] (int i)\n+\n+ void set_item(int ndx, py::object& val)\n+ void set_item(int ndx, int val)\n+ void set_item(int ndx, double val)\n+ void set_item(int ndx, char* val)\n+ void set_item(int ndx, std::string val)\n+\n+ void set_slice(int lo, int hi, const py::sequence& slice)\n+\n+ py::list& append(const py::object& other)\n+ py::list& append(int other)\n+ py::list& append(double other)\n+ py::list& append(char* other)\n+ py::list& append(std::string other)\n+ \n+ py::list& insert(int ndx, py::object& other)\n+ py::list& insert(int ndx, int other);\n+ py::list& insert(int ndx, double other);\n+ py::list& insert(int ndx, char* other); \n+ py::list& insert(int ndx, std::string other);\n+\n+ py::list& reverse()\n+ py::list& sort()\n+\n+ class py::dict\n+ py::dict_member operator [] (const char* key)\n+ py::dict_member operator [] (std::string key)\n+ \n+ py::dict_member operator [] (PyObject* key)\n+ py::dict_member operator [] (int key) \n+ py::dict_member operator [] (double key)\n+ \n+ bool has_key(PyObject* key) const\n+ bool has_key(const char* key) const\n+ // needs int, std::string, and double versions\n+ \n+ int len() const\n+ int length() const\n+\n+ void set_item(const char* key, PyObject* val)\n+ void set_item(PyObject* key, PyObject* val) const\n+ // need int, std::string and double versions\n+ void clear()\n+ \n+ void del(PyObject* key)\n+ void del(const char* key)\n+ // need int, std::string, and double versions\n+ \n+ py::list items() const\n+ py::list keys() const\n+ py::list values() const\n\\ No newline at end of file\n", "added_lines": 161, "deleted_lines": 0, "source_code": "base package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nProposed changes:\n\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n\n\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "base package", " scipy_base", " scipy_distutils", " scipy_test", " gui_thread", "", "scipy", "weave", "chaco", "", "weave", "", "Proposed changes:", "", "* all classes moved to py:: namespace", "* made tuples mutable with indexing notation. (handy in weave)", "* converted camel case names (setItem -> set_item)", "", "", "* change class names to reflect boost like names and put each", " exposed class in its own header file.", " PWOBase -> py::object -- object.h", " PWOList -> py::list -- list.h", " PWOTuple -> py::tuple -- tuple.h", " PWOMapping -> py::dict -- dict.h", " PWOCallable -> py::callable -- callable.h", " PWOString -> py::str -- str.h", " PWONumber -> py::number -- number.h", "", " py::object public methods:", " int print(FILE *f, int flags) const DONE", "", " bool hasattr(const char* nm) const DONE", "", " py::object_attr attr(const char* nm) const", " py::object_attr attr(const py::object& nm) const", "", " ??", " int set_attr(const char* nm, py::object& val)", " int set_attr(PyObject* nm, py::object& val)", "", " int del(const char* nm)", " int del(const py::object& nm)", "", " int cmp(const py::object& other) const", "", " bool operator == (const py::object& other) const", " bool operator != (const py::object& other) const", " bool operator > (const py::object& other) const", " bool operator < (const py::object& other) const", " bool operator >= (const py::object& other) const", " bool operator <= (const py::object& other) const", "", " PyObject* repr() const", " /*PyObject* str() const*/ // conflicts with class named str", " PyObject* type() const", "", " int hash() const", " bool is_true() const", " bool is_callable() const", "", " PyObject* disown()", "", "", " py::sequence public methods:", " PWOSequence operator+(const PWOSequence& rhs) const", " //count", " int count(const py::object& value) const", " int count(int value) const;", " int count(double value) const;", " int count(char* value) const;", " int count(std::string value) const;", "", " py::object operator [] (int i) const", " py::sequence get_slice(int lo, int hi) const", "", " bool in(const py::object& value) const", " bool in(int value);", " bool in(double value);", " bool in(char* value);", " bool in(std::string value);", "", " int index(const py::object& value) const", " int index(int value) const;", " int index(double value) const;", " int index(char* value) const;", " int index(std::string value) const;", "", " int len() const", " int length() const // compatible with std::string", "", " py::sequence operator * (int count) const //repeat", "", " class py::tuple", " void set_item(int ndx, py::object& val)", " void set_item(int ndx, int val)", " void set_item(int ndx, double val)", " void set_item(int ndx, char* val)", " void set_item(int ndx, std::string val)", "", " // make tuples mutable like lists", " // much easier to set up call lists, etc.", " py::tuple_member operator [] (int i)", "", " class py::list", "", " bool del(int i)", " bool del(int lo, int hi)", "", " py::list_member operator [] (int i)", "", " void set_item(int ndx, py::object& val)", " void set_item(int ndx, int val)", " void set_item(int ndx, double val)", " void set_item(int ndx, char* val)", " void set_item(int ndx, std::string val)", "", " void set_slice(int lo, int hi, const py::sequence& slice)", "", " py::list& append(const py::object& other)", " py::list& append(int other)", " py::list& append(double other)", " py::list& append(char* other)", " py::list& append(std::string other)", "", " py::list& insert(int ndx, py::object& other)", " py::list& insert(int ndx, int other);", " py::list& insert(int ndx, double other);", " py::list& insert(int ndx, char* other);", " py::list& insert(int ndx, std::string other);", "", " py::list& reverse()", " py::list& sort()", "", " class py::dict", " py::dict_member operator [] (const char* key)", " py::dict_member operator [] (std::string key)", "", " py::dict_member operator [] (PyObject* key)", " py::dict_member operator [] (int key)", " py::dict_member operator [] (double key)", "", " bool has_key(PyObject* key) const", " bool has_key(const char* key) const", " // needs int, std::string, and double versions", "", " int len() const", " int length() const", "", " void set_item(const char* key, PyObject* val)", " void set_item(PyObject* key, PyObject* val) const", " // need int, std::string and double versions", " void clear()", "", " void del(PyObject* key)", " void del(const char* key)", " // need int, std::string, and double versions", "", " py::list items() const", " py::list keys() const", " py::list values() const" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/number.h", "filename": "number.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,186 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+\n+ modified for weave by eric jones\n+*********************************************/\n+#if !defined(NUMBER_H_INCLUDED_)\n+#define NUMBER_H_INCLUDED_\n+\n+#include \"object.h\"\n+#include \"sequence.h\"\n+\n+namespace py {\n+ \n+class number : public object\n+{\n+public:\n+ number() : object() {};\n+ number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n+ number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n+ number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n+ number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n+\n+ number(const number& other) : object(other) {};\n+ number(PyObject* obj) : object(obj) {\n+ _violentTypeCheck();\n+ };\n+ virtual ~number() {};\n+\n+ virtual number& operator=(const number& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ /*virtual*/ number& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PyNumber_Check(_obj)) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a number\");\n+ }\n+ };\n+ //PyNumber_Absolute\n+ number abs() const {\n+ PyObject* rslt = PyNumber_Absolute(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Failed to get absolute value\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Add\n+ number operator+(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Add(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for +\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_And\n+ number operator&(const number& rhs) const {\n+ PyObject* rslt = PyNumber_And(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for &\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Coerce\n+ //PyNumber_Divide\n+ number operator/(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Divide(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for /\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Divmod\n+ sequence divmod(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Float\n+ operator double () const {\n+ PyObject* F = PyNumber_Float(_obj);\n+ if (F==0)\n+ Fail(PyExc_TypeError, \"Cannot convert to double\");\n+ double r = PyFloat_AS_DOUBLE(F);\n+ Py_DECREF(F);\n+ return r;\n+ };\n+ operator float () const {\n+ double rslt = (double) *this;\n+ //if (rslt > INT_MAX)\n+ // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n+ return (float) rslt;\n+ };\n+ //PyNumber_Int\n+ operator long () const {\n+ PyObject* Int = PyNumber_Int(_obj);\n+ if (Int==0)\n+ Fail(PyExc_TypeError, \"Cannot convert to long\");\n+ long r = PyInt_AS_LONG(Int);\n+ Py_DECREF(Int);\n+ return r;\n+ };\n+ operator int () const {\n+ long rslt = (long) *this;\n+ if (rslt > INT_MAX)\n+ Fail(PyExc_TypeError, \"Cannot convert to an int\");\n+ return (int) rslt;\n+ };\n+ //PyNumber_Invert\n+ number operator~ () const {\n+ PyObject* rslt = PyNumber_Invert(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper type for ~\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Long\n+ //PyNumber_Lshift\n+ number operator<<(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for <<\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Multiply\n+ number operator*(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for *\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Negative\n+ number operator- () const {\n+ PyObject* rslt = PyNumber_Negative(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper type for unary -\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Or\n+ number operator|(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Or(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for |\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Positive\n+ number operator+ () const {\n+ PyObject* rslt = PyNumber_Positive(_obj);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper type for unary +\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Remainder\n+ number operator%(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for %\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Rshift\n+ number operator>>(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for >>\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Subtract\n+ number operator-(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for -\");\n+ return LoseRef(rslt);\n+ };\n+ //PyNumber_Xor\n+ number operator^(const number& rhs) const {\n+ PyObject* rslt = PyNumber_Xor(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for ^\");\n+ return LoseRef(rslt);\n+ };\n+};\n+\n+} // namespace py\n+\n+#endif //NUMBER_H_INCLUDED_\n", "added_lines": 186, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(NUMBER_H_INCLUDED_)\n#define NUMBER_H_INCLUDED_\n\n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n \nclass number : public object\n{\npublic:\n number() : object() {};\n number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n\n number(const number& other) : object(other) {};\n number(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~number() {};\n\n virtual number& operator=(const number& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ number& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyNumber_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a number\");\n }\n };\n //PyNumber_Absolute\n number abs() const {\n PyObject* rslt = PyNumber_Absolute(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Failed to get absolute value\");\n return LoseRef(rslt);\n };\n //PyNumber_Add\n number operator+(const number& rhs) const {\n PyObject* rslt = PyNumber_Add(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n //PyNumber_And\n number operator&(const number& rhs) const {\n PyObject* rslt = PyNumber_And(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for &\");\n return LoseRef(rslt);\n };\n //PyNumber_Coerce\n //PyNumber_Divide\n number operator/(const number& rhs) const {\n PyObject* rslt = PyNumber_Divide(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for /\");\n return LoseRef(rslt);\n };\n //PyNumber_Divmod\n sequence divmod(const number& rhs) const {\n PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n return LoseRef(rslt);\n };\n //PyNumber_Float\n operator double () const {\n PyObject* F = PyNumber_Float(_obj);\n if (F==0)\n Fail(PyExc_TypeError, \"Cannot convert to double\");\n double r = PyFloat_AS_DOUBLE(F);\n Py_DECREF(F);\n return r;\n };\n operator float () const {\n double rslt = (double) *this;\n //if (rslt > INT_MAX)\n // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n return (float) rslt;\n };\n //PyNumber_Int\n operator long () const {\n PyObject* Int = PyNumber_Int(_obj);\n if (Int==0)\n Fail(PyExc_TypeError, \"Cannot convert to long\");\n long r = PyInt_AS_LONG(Int);\n Py_DECREF(Int);\n return r;\n };\n operator int () const {\n long rslt = (long) *this;\n if (rslt > INT_MAX)\n Fail(PyExc_TypeError, \"Cannot convert to an int\");\n return (int) rslt;\n };\n //PyNumber_Invert\n number operator~ () const {\n PyObject* rslt = PyNumber_Invert(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for ~\");\n return LoseRef(rslt);\n };\n //PyNumber_Long\n //PyNumber_Lshift\n number operator<<(const number& rhs) const {\n PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for <<\");\n return LoseRef(rslt);\n };\n //PyNumber_Multiply\n number operator*(const number& rhs) const {\n PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for *\");\n return LoseRef(rslt);\n };\n //PyNumber_Negative\n number operator- () const {\n PyObject* rslt = PyNumber_Negative(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary -\");\n return LoseRef(rslt);\n };\n //PyNumber_Or\n number operator|(const number& rhs) const {\n PyObject* rslt = PyNumber_Or(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for |\");\n return LoseRef(rslt);\n };\n //PyNumber_Positive\n number operator+ () const {\n PyObject* rslt = PyNumber_Positive(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary +\");\n return LoseRef(rslt);\n };\n //PyNumber_Remainder\n number operator%(const number& rhs) const {\n PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for %\");\n return LoseRef(rslt);\n };\n //PyNumber_Rshift\n number operator>>(const number& rhs) const {\n PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for >>\");\n return LoseRef(rslt);\n };\n //PyNumber_Subtract\n number operator-(const number& rhs) const {\n PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for -\");\n return LoseRef(rslt);\n };\n //PyNumber_Xor\n number operator^(const number& rhs) const {\n PyObject* rslt = PyNumber_Xor(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for ^\");\n return LoseRef(rslt);\n };\n};\n\n} // namespace py\n\n#endif //NUMBER_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::number::number", "long_name": "py::number::number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( int i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( unsigned long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 21, "parameters": [ "i" ], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( double d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "d" ], "start_line": 22, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( const number & other)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( PyObject * obj)", "filename": "number.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::number::~number", "long_name": "py::number::~number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 28, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const number & other)", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const object & other)", "filename": "number.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::number::_violentTypeCheck", "long_name": "py::number::_violentTypeCheck()", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::abs", "long_name": "py::number::abs() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator &", "long_name": "py::number::operator &( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator /", "long_name": "py::number::operator /( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::divmod", "long_name": "py::number::divmod( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 75, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator double", "long_name": "py::number::operator double() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator float", "long_name": "py::number::operator float() const", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 90, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator long", "long_name": "py::number::operator long() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 97, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator int", "long_name": "py::number::operator int() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ~ ", "long_name": "py::number::operator ~ () const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator < <", "long_name": "py::number::operator < <( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator *", "long_name": "py::number::operator *( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator |", "long_name": "py::number::operator |( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 141, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator %", "long_name": "py::number::operator %( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 155, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator > >", "long_name": "py::number::operator > >( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 162, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 169, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ^", "long_name": "py::number::operator ^( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::number::number", "long_name": "py::number::number( int i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( const number & other)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ~ ", "long_name": "py::number::operator ~ () const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator int", "long_name": "py::number::operator int() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::_violentTypeCheck", "long_name": "py::number::_violentTypeCheck()", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator double", "long_name": "py::number::operator double() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator ^", "long_name": "py::number::operator ^( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( PyObject * obj)", "filename": "number.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 169, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const number & other)", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( double d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "d" ], "start_line": 22, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( unsigned long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 21, "parameters": [ "i" ], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const object & other)", "filename": "number.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::number::operator < <", "long_name": "py::number::operator < <( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator > >", "long_name": "py::number::operator > >( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 162, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator *", "long_name": "py::number::operator *( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::divmod", "long_name": "py::number::divmod( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 75, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator /", "long_name": "py::number::operator /( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::abs", "long_name": "py::number::abs() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator float", "long_name": "py::number::operator float() const", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 90, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator long", "long_name": "py::number::operator long() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 97, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator %", "long_name": "py::number::operator %( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 155, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::~number", "long_name": "py::number::~number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 28, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator &", "long_name": "py::number::operator &( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator |", "long_name": "py::number::operator |( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 141, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 149, "complexity": 49, "token_count": 1000, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified for weave by eric jones", "*********************************************/", "#if !defined(NUMBER_H_INCLUDED_)", "#define NUMBER_H_INCLUDED_", "", "#include \"object.h\"", "#include \"sequence.h\"", "", "namespace py {", "", "class number : public object", "{", "public:", " number() : object() {};", " number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }", " number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }", " number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }", " number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }", "", " number(const number& other) : object(other) {};", " number(PyObject* obj) : object(obj) {", " _violentTypeCheck();", " };", " virtual ~number() {};", "", " virtual number& operator=(const number& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ number& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyNumber_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a number\");", " }", " };", " //PyNumber_Absolute", " number abs() const {", " PyObject* rslt = PyNumber_Absolute(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Failed to get absolute value\");", " return LoseRef(rslt);", " };", " //PyNumber_Add", " number operator+(const number& rhs) const {", " PyObject* rslt = PyNumber_Add(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " };", " //PyNumber_And", " number operator&(const number& rhs) const {", " PyObject* rslt = PyNumber_And(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for &\");", " return LoseRef(rslt);", " };", " //PyNumber_Coerce", " //PyNumber_Divide", " number operator/(const number& rhs) const {", " PyObject* rslt = PyNumber_Divide(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for /\");", " return LoseRef(rslt);", " };", " //PyNumber_Divmod", " sequence divmod(const number& rhs) const {", " PyObject* rslt = PyNumber_Divmod(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for divmod\");", " return LoseRef(rslt);", " };", " //PyNumber_Float", " operator double () const {", " PyObject* F = PyNumber_Float(_obj);", " if (F==0)", " Fail(PyExc_TypeError, \"Cannot convert to double\");", " double r = PyFloat_AS_DOUBLE(F);", " Py_DECREF(F);", " return r;", " };", " operator float () const {", " double rslt = (double) *this;", " //if (rslt > INT_MAX)", " // Fail(PyExc_TypeError, \"Cannot convert to a float\");", " return (float) rslt;", " };", " //PyNumber_Int", " operator long () const {", " PyObject* Int = PyNumber_Int(_obj);", " if (Int==0)", " Fail(PyExc_TypeError, \"Cannot convert to long\");", " long r = PyInt_AS_LONG(Int);", " Py_DECREF(Int);", " return r;", " };", " operator int () const {", " long rslt = (long) *this;", " if (rslt > INT_MAX)", " Fail(PyExc_TypeError, \"Cannot convert to an int\");", " return (int) rslt;", " };", " //PyNumber_Invert", " number operator~ () const {", " PyObject* rslt = PyNumber_Invert(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for ~\");", " return LoseRef(rslt);", " };", " //PyNumber_Long", " //PyNumber_Lshift", " number operator<<(const number& rhs) const {", " PyObject* rslt = PyNumber_Lshift(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for <<\");", " return LoseRef(rslt);", " };", " //PyNumber_Multiply", " number operator*(const number& rhs) const {", " PyObject* rslt = PyNumber_Multiply(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for *\");", " return LoseRef(rslt);", " };", " //PyNumber_Negative", " number operator- () const {", " PyObject* rslt = PyNumber_Negative(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for unary -\");", " return LoseRef(rslt);", " };", " //PyNumber_Or", " number operator|(const number& rhs) const {", " PyObject* rslt = PyNumber_Or(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for |\");", " return LoseRef(rslt);", " };", " //PyNumber_Positive", " number operator+ () const {", " PyObject* rslt = PyNumber_Positive(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for unary +\");", " return LoseRef(rslt);", " };", " //PyNumber_Remainder", " number operator%(const number& rhs) const {", " PyObject* rslt = PyNumber_Remainder(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for %\");", " return LoseRef(rslt);", " };", " //PyNumber_Rshift", " number operator>>(const number& rhs) const {", " PyObject* rslt = PyNumber_Rshift(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for >>\");", " return LoseRef(rslt);", " };", " //PyNumber_Subtract", " number operator-(const number& rhs) const {", " PyObject* rslt = PyNumber_Subtract(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for -\");", " return LoseRef(rslt);", " };", " //PyNumber_Xor", " number operator^(const number& rhs) const {", " PyObject* rslt = PyNumber_Xor(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for ^\");", " return LoseRef(rslt);", " };", "};", "", "} // namespace py", "", "#endif //NUMBER_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,134 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+\n+ modified heavily for weave by eric jones.\n+*********************************************/\n+\n+#if !defined(OBJECT_H_INCLUDED_)\n+#define OBJECT_H_INCLUDED_\n+\n+#include \n+#include \n+\n+namespace py {\n+\n+void Fail(PyObject*, const char* msg);\n+ \n+class object \n+{\n+protected:\n+ PyObject* _obj;\n+\n+ // incref new owner, decref old owner, and adjust to new owner\n+ void GrabRef(PyObject* newObj);\n+ // decrease reference count without destroying the object\n+ static PyObject* LoseRef(PyObject* o)\n+ { if (o != 0) --(o->ob_refcnt); return o; }\n+\n+private:\n+ PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n+\n+public:\n+ object()\n+ : _obj (0), _own (0) { }\n+ object(const object& other)\n+ : _obj (0), _own (0) { GrabRef(other); }\n+ object(PyObject* obj)\n+ : _obj (0), _own (0) { GrabRef(obj); }\n+\n+ virtual ~object()\n+ { Py_XDECREF(_own); }\n+ \n+ object& operator=(const object& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ operator PyObject* () const {\n+ return _obj;\n+ };\n+ int print(FILE *f, int flags) const {\n+ return PyObject_Print(_obj, f, flags);\n+ };\n+ bool hasattr(const char* nm) const {\n+ return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n+ };\n+\n+ // Need to change return type?\n+ PyObject* attr(const char* nm) const {\n+ return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n+ };\n+ PyObject* attr(const object& nm) const {\n+ return LoseRef(PyObject_GetAttr(_obj, nm));\n+ };\n+ \n+ \n+ int set_attr(const char* nm, object& val) {\n+ return PyObject_SetAttrString(_obj, (char*) nm, val);\n+ };\n+ int set_attr(PyObject* nm, object& val) {\n+ return PyObject_SetAttr(_obj, nm, val);\n+ };\n+ \n+ int del(const char* nm) {\n+ return PyObject_DelAttrString(_obj, (char*) nm);\n+ };\n+ int del(const object& nm) {\n+ return PyObject_DelAttr(_obj, nm);\n+ };\n+ \n+ int cmp(const object& other) const {\n+ int rslt = 0;\n+ int rc = PyObject_Cmp(_obj, other, &rslt);\n+ if (rc == -1)\n+ Fail(PyExc_TypeError, \"cannot make the comparison\");\n+ return rslt;\n+ };\n+ bool operator == (const object& other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator != (const object& other) const {\n+ return cmp(other) != 0;\n+ };\n+ bool operator > (const object& other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator < (const object& other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator >= (const object& other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator <= (const object& other) const {\n+ return cmp(other) <= 0;\n+ };\n+ \n+ PyObject* repr() const {\n+ return LoseRef(PyObject_Repr(_obj));\n+ };\n+ /*\n+ PyObject* str() const {\n+ return LoseRef(PyObject_Str(_obj));\n+ };\n+ */\n+ bool is_callable() const {\n+ return PyCallable_Check(_obj) == 1;\n+ };\n+ int hash() const {\n+ return PyObject_Hash(_obj);\n+ };\n+ bool is_true() const {\n+ return PyObject_IsTrue(_obj) == 1;\n+ };\n+ PyObject* type() const {\n+ return LoseRef(PyObject_Type(_obj));\n+ };\n+ PyObject* disown() {\n+ _own = 0;\n+ return _obj;\n+ };\n+};\n+\n+} // namespace\n+\n+#endif // !defined(OBJECT_H_INCLUDED_)\n", "added_lines": 134, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n PyObject* attr(const char* nm) const {\n return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n };\n PyObject* attr(const object& nm) const {\n return LoseRef(PyObject_GetAttr(_obj, nm));\n };\n \n \n int set_attr(const char* nm, object& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n };\n int set_attr(PyObject* nm, object& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n \n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": null, "methods": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 33, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 43, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 50, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 61, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 69, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 76, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 80, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 99, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 99, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 43, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 76, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 50, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 69, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 33, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 80, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 61, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "nloc": 99, "complexity": 30, "token_count": 648, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified heavily for weave by eric jones.", "*********************************************/", "", "#if !defined(OBJECT_H_INCLUDED_)", "#define OBJECT_H_INCLUDED_", "", "#include ", "#include ", "", "namespace py {", "", "void Fail(PyObject*, const char* msg);", "", "class object", "{", "protected:", " PyObject* _obj;", "", " // incref new owner, decref old owner, and adjust to new owner", " void GrabRef(PyObject* newObj);", " // decrease reference count without destroying the object", " static PyObject* LoseRef(PyObject* o)", " { if (o != 0) --(o->ob_refcnt); return o; }", "", "private:", " PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero", "", "public:", " object()", " : _obj (0), _own (0) { }", " object(const object& other)", " : _obj (0), _own (0) { GrabRef(other); }", " object(PyObject* obj)", " : _obj (0), _own (0) { GrabRef(obj); }", "", " virtual ~object()", " { Py_XDECREF(_own); }", "", " object& operator=(const object& other) {", " GrabRef(other);", " return *this;", " };", " operator PyObject* () const {", " return _obj;", " };", " int print(FILE *f, int flags) const {", " return PyObject_Print(_obj, f, flags);", " };", " bool hasattr(const char* nm) const {", " return PyObject_HasAttrString(_obj, (char*) nm) == 1;", " };", "", " // Need to change return type?", " PyObject* attr(const char* nm) const {", " return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));", " };", " PyObject* attr(const object& nm) const {", " return LoseRef(PyObject_GetAttr(_obj, nm));", " };", "", "", " int set_attr(const char* nm, object& val) {", " return PyObject_SetAttrString(_obj, (char*) nm, val);", " };", " int set_attr(PyObject* nm, object& val) {", " return PyObject_SetAttr(_obj, nm, val);", " };", "", " int del(const char* nm) {", " return PyObject_DelAttrString(_obj, (char*) nm);", " };", " int del(const object& nm) {", " return PyObject_DelAttr(_obj, nm);", " };", "", " int cmp(const object& other) const {", " int rslt = 0;", " int rc = PyObject_Cmp(_obj, other, &rslt);", " if (rc == -1)", " Fail(PyExc_TypeError, \"cannot make the comparison\");", " return rslt;", " };", " bool operator == (const object& other) const {", " return cmp(other) == 0;", " };", " bool operator != (const object& other) const {", " return cmp(other) != 0;", " };", " bool operator > (const object& other) const {", " return cmp(other) > 0;", " };", " bool operator < (const object& other) const {", " return cmp(other) < 0;", " };", " bool operator >= (const object& other) const {", " return cmp(other) >= 0;", " };", " bool operator <= (const object& other) const {", " return cmp(other) <= 0;", " };", "", " PyObject* repr() const {", " return LoseRef(PyObject_Repr(_obj));", " };", " /*", " PyObject* str() const {", " return LoseRef(PyObject_Str(_obj));", " };", " */", " bool is_callable() const {", " return PyCallable_Check(_obj) == 1;", " };", " int hash() const {", " return PyObject_Hash(_obj);", " };", " bool is_true() const {", " return PyObject_IsTrue(_obj) == 1;", " };", " PyObject* type() const {", " return LoseRef(PyObject_Type(_obj));", " };", " PyObject* disown() {", " _own = 0;", " return _obj;", " };", "};", "", "} // namespace", "", "#endif // !defined(OBJECT_H_INCLUDED_)" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/scxx2.h", "filename": "scxx2.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,8 @@\n+#include \"object.h\"\n+#include \"dict.h\"\n+#include \"tuple.h\"\n+#include \"str.h\"\n+#include \"list.h\"\n+#include \"number.h\"\n+#include \"callable.h\"\n+\n", "added_lines": 8, "deleted_lines": 0, "source_code": "#include \"object.h\"\n#include \"dict.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"list.h\"\n#include \"number.h\"\n#include \"callable.h\"\n\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": 7, "complexity": 0, "token_count": 14, "diff_parsed": { "added": [ "#include \"object.h\"", "#include \"dict.h\"", "#include \"tuple.h\"", "#include \"str.h\"", "#include \"list.h\"", "#include \"number.h\"", "#include \"callable.h\"", "" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/sequence.h", "filename": "sequence.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,133 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+ \n+ modified heavily for weave by eric jones\n+*********************************************/\n+#if !defined(SEQUENCE_H_INCLUDED_)\n+#define SEQUENCE_H_INCLUDED_\n+\n+#include \n+#include \"object.h\"\n+\n+namespace py {\n+ \n+// This isn't being picked up out of object.h for some reason\n+void Fail(PyObject*, const char* msg);\n+\n+// pre-declared. needed by other include files\n+class str;\n+class tuple;\n+class list;\n+\n+class sequence : public object\n+{\n+public:\n+ sequence() : object() {};\n+ sequence(const sequence& other) : object(other) {};\n+ sequence(PyObject* obj) : object(obj) {\n+ _violentTypeCheck();\n+ };\n+ virtual ~sequence() {}\n+\n+ virtual sequence& operator=(const sequence& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ /*virtual*/ sequence& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PySequence_Check(_obj)) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a sequence\");\n+ }\n+ };\n+ //PySequence_Concat\n+ sequence operator+(const sequence& rhs) const {\n+ PyObject* rslt = PySequence_Concat(_obj, rhs);\n+ if (rslt==0)\n+ Fail(PyExc_TypeError, \"Improper rhs for +\");\n+ return LoseRef(rslt);\n+ };\n+\n+ //PySequence_Count\n+ int count(const object& value) const {\n+ int rslt = PySequence_Count(_obj, value);\n+ if (rslt == -1)\n+ Fail(PyExc_RuntimeError, \"failure in count\");\n+ return rslt;\n+ };\n+\n+ int count(int value) const;\n+ int count(double value) const; \n+ int count(char* value) const;\n+ int count(std::string value) const;\n+ \n+ //PySequence_GetItem \n+ // ## lists - return list_member (mutable) \n+ // ## tuples - return tuple_member (mutable)\n+ // ## otherwise just a object\n+ object operator [] (int i) const { //can't be virtual\n+ PyObject* o = PySequence_GetItem(_obj, i);\n+ if (o == 0)\n+ Fail(PyExc_IndexError, \"index out of range\");\n+ return LoseRef(o);\n+ };\n+ //PySequence_GetSlice\n+ //virtual sequence& operator [] (PWSlice& x) {...};\n+ sequence slice(int lo, int hi) const {\n+ PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n+ if (o == 0)\n+ Fail(PyExc_IndexError, \"could not obtain slice\");\n+ return LoseRef(o);\n+ };\n+ \n+ //PySequence_In\n+ bool in(const object& value) const {\n+ int rslt = PySequence_In(_obj, value);\n+ if (rslt==-1)\n+ Fail(PyExc_RuntimeError, \"problem in in\");\n+ return (rslt==1);\n+ };\n+ \n+ bool in(int value); \n+ bool in(double value);\n+ bool in(char* value);\n+ bool in(std::string value);\n+ \n+ //PySequence_Index\n+ int index(const object& value) const {\n+ int rslt = PySequence_Index(_obj, value);\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"value not found\");\n+ return rslt;\n+ };\n+ int index(int value) const;\n+ int index(double value) const;\n+ int index(char* value) const;\n+ int index(std::string value) const; \n+ \n+ //PySequence_Length\n+ int len() const {\n+ return PySequence_Length(_obj);\n+ };\n+ // added length for compatibility with std::string.\n+ int length() const {\n+ return PySequence_Length(_obj);\n+ };\n+ //PySequence_Repeat\n+ sequence operator * (int count) const {\n+ PyObject* rslt = PySequence_Repeat(_obj, count);\n+ if (rslt==0)\n+ Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n+ return LoseRef(rslt);\n+ };\n+ //PySequence_Tuple\n+};\n+\n+} // namespace py\n+\n+#endif // PWOSEQUENCE_H_INCLUDED_\n", "added_lines": 133, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified heavily for weave by eric jones\n*********************************************/\n#if !defined(SEQUENCE_H_INCLUDED_)\n#define SEQUENCE_H_INCLUDED_\n\n#include \n#include \"object.h\"\n\nnamespace py {\n \n// This isn't being picked up out of object.h for some reason\nvoid Fail(PyObject*, const char* msg);\n\n// pre-declared. needed by other include files\nclass str;\nclass tuple;\nclass list;\n\nclass sequence : public object\n{\npublic:\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~sequence() {}\n\n virtual sequence& operator=(const sequence& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n //PySequence_Concat\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n\n //PySequence_Count\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n //PySequence_GetItem \n // ## lists - return list_member (mutable) \n // ## tuples - return tuple_member (mutable)\n // ## otherwise just a object\n object operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n if (o == 0)\n Fail(PyExc_IndexError, \"index out of range\");\n return LoseRef(o);\n };\n //PySequence_GetSlice\n //virtual sequence& operator [] (PWSlice& x) {...};\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n Fail(PyExc_IndexError, \"could not obtain slice\");\n return LoseRef(o);\n };\n \n //PySequence_In\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n \n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n //PySequence_Index\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n };\n // added length for compatibility with std::string.\n int length() const {\n return PySequence_Length(_obj);\n };\n //PySequence_Repeat\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return LoseRef(rslt);\n };\n //PySequence_Tuple\n};\n\n} // namespace py\n\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 26, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 28, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 73, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 81, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 102, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::len", "long_name": "py::sequence::len() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::length", "long_name": "py::sequence::length() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 122, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 102, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::length", "long_name": "py::sequence::length() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 122, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 73, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::len", "long_name": "py::sequence::len() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 28, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 81, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 26, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 93, "complexity": 24, "token_count": 588, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified heavily for weave by eric jones", "*********************************************/", "#if !defined(SEQUENCE_H_INCLUDED_)", "#define SEQUENCE_H_INCLUDED_", "", "#include ", "#include \"object.h\"", "", "namespace py {", "", "// This isn't being picked up out of object.h for some reason", "void Fail(PyObject*, const char* msg);", "", "// pre-declared. needed by other include files", "class str;", "class tuple;", "class list;", "", "class sequence : public object", "{", "public:", " sequence() : object() {};", " sequence(const sequence& other) : object(other) {};", " sequence(PyObject* obj) : object(obj) {", " _violentTypeCheck();", " };", " virtual ~sequence() {}", "", " virtual sequence& operator=(const sequence& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ sequence& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PySequence_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a sequence\");", " }", " };", " //PySequence_Concat", " sequence operator+(const sequence& rhs) const {", " PyObject* rslt = PySequence_Concat(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " };", "", " //PySequence_Count", " int count(const object& value) const {", " int rslt = PySequence_Count(_obj, value);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"failure in count\");", " return rslt;", " };", "", " int count(int value) const;", " int count(double value) const;", " int count(char* value) const;", " int count(std::string value) const;", "", " //PySequence_GetItem", " // ## lists - return list_member (mutable)", " // ## tuples - return tuple_member (mutable)", " // ## otherwise just a object", " object operator [] (int i) const { //can't be virtual", " PyObject* o = PySequence_GetItem(_obj, i);", " if (o == 0)", " Fail(PyExc_IndexError, \"index out of range\");", " return LoseRef(o);", " };", " //PySequence_GetSlice", " //virtual sequence& operator [] (PWSlice& x) {...};", " sequence slice(int lo, int hi) const {", " PyObject* o = PySequence_GetSlice(_obj, lo, hi);", " if (o == 0)", " Fail(PyExc_IndexError, \"could not obtain slice\");", " return LoseRef(o);", " };", "", " //PySequence_In", " bool in(const object& value) const {", " int rslt = PySequence_In(_obj, value);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"problem in in\");", " return (rslt==1);", " };", "", " bool in(int value);", " bool in(double value);", " bool in(char* value);", " bool in(std::string value);", "", " //PySequence_Index", " int index(const object& value) const {", " int rslt = PySequence_Index(_obj, value);", " if (rslt==-1)", " Fail(PyExc_IndexError, \"value not found\");", " return rslt;", " };", " int index(int value) const;", " int index(double value) const;", " int index(char* value) const;", " int index(std::string value) const;", "", " //PySequence_Length", " int len() const {", " return PySequence_Length(_obj);", " };", " // added length for compatibility with std::string.", " int length() const {", " return PySequence_Length(_obj);", " };", " //PySequence_Repeat", " sequence operator * (int count) const {", " PyObject* rslt = PySequence_Repeat(_obj, count);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"sequence repeat failed\");", " return LoseRef(rslt);", " };", " //PySequence_Tuple", "};", "", "} // namespace py", "", "#endif // PWOSEQUENCE_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/str.h", "filename": "str.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,62 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+ \n+ modified heavily for weave by eric jones\n+*********************************************/\n+#if !defined(STR_H_INCLUDED_)\n+#define STR_H_INCLUDED_\n+\n+#include \n+#include \"object.h\"\n+#include \"sequence.h\"\n+\n+namespace py {\n+\n+class str : public sequence\n+{\n+public:\n+ str() : sequence() {};\n+ str(const char* s)\n+ : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n+ str(const char* s, int sz)\n+ : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n+ str(const str& other)\n+ : sequence(other) {};\n+ str(PyObject* obj)\n+ : sequence(obj) { _violentTypeCheck(); };\n+ str(const object& other)\n+ : sequence(other) { _violentTypeCheck(); };\n+ virtual ~str() {};\n+\n+ virtual str& operator=(const str& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ str& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PyString_Check(_obj)) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a Python String\");\n+ }\n+ };\n+ operator const char* () const {\n+ return PyString_AsString(_obj);\n+ };\n+ /*\n+ static str format(const str& fmt, tuple& args){\n+ PyObject * rslt =PyString_Format(fmt, args);\n+ if (rslt==0)\n+ Fail(PyExc_RuntimeError, \"string format failed\");\n+ return LoseRef(rslt);\n+ };\n+ */\n+}; // class str\n+\n+} // namespace\n+\n+#endif // STR_H_INCLUDED_\n", "added_lines": 62, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified heavily for weave by eric jones\n*********************************************/\n#if !defined(STR_H_INCLUDED_)\n#define STR_H_INCLUDED_\n\n#include \n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n\nclass str : public sequence\n{\npublic:\n str() : sequence() {};\n str(const char* s)\n : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n str(const char* s, int sz)\n : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n str(const str& other)\n : sequence(other) {};\n str(PyObject* obj)\n : sequence(obj) { _violentTypeCheck(); };\n str(const object& other)\n : sequence(other) { _violentTypeCheck(); };\n virtual ~str() {};\n\n virtual str& operator=(const str& other) {\n GrabRef(other);\n return *this;\n };\n str& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n /*\n static str format(const str& fmt, tuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"string format failed\");\n return LoseRef(rslt);\n };\n */\n}; // class str\n\n} // namespace\n\n#endif // STR_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::str::str", "long_name": "py::str::str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s , int sz)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 22, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const str & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( PyObject * obj)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const object & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 28, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::~str", "long_name": "py::str::~str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const str & other)", "filename": "str.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const object & other)", "filename": "str.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::str::_violentTypeCheck", "long_name": "py::str::_violentTypeCheck()", "filename": "str.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::str::operator const char *", "long_name": "py::str::operator const char *() const", "filename": "str.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::str::str", "long_name": "py::str::str( const str & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::operator const char *", "long_name": "py::str::operator const char *() const", "filename": "str.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const object & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 28, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const object & other)", "filename": "str.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const str & other)", "filename": "str.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::str::~str", "long_name": "py::str::~str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s , int sz)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 22, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( PyObject * obj)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::_violentTypeCheck", "long_name": "py::str::_violentTypeCheck()", "filename": "str.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 39, "complexity": 12, "token_count": 241, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified heavily for weave by eric jones", "*********************************************/", "#if !defined(STR_H_INCLUDED_)", "#define STR_H_INCLUDED_", "", "#include ", "#include \"object.h\"", "#include \"sequence.h\"", "", "namespace py {", "", "class str : public sequence", "{", "public:", " str() : sequence() {};", " str(const char* s)", " : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }", " str(const char* s, int sz)", " : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }", " str(const str& other)", " : sequence(other) {};", " str(PyObject* obj)", " : sequence(obj) { _violentTypeCheck(); };", " str(const object& other)", " : sequence(other) { _violentTypeCheck(); };", " virtual ~str() {};", "", " virtual str& operator=(const str& other) {", " GrabRef(other);", " return *this;", " };", " str& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyString_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python String\");", " }", " };", " operator const char* () const {", " return PyString_AsString(_obj);", " };", " /*", " static str format(const str& fmt, tuple& args){", " PyObject * rslt =PyString_Format(fmt, args);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"string format failed\");", " return LoseRef(rslt);", " };", " */", "}; // class str", "", "} // namespace", "", "#endif // STR_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/tuple.h", "filename": "tuple.h", "extension": "h", "change_type": "ADD", "diff": "@@ -0,0 +1,96 @@\n+#if !defined(TUPLE_H_INCLUDED_)\n+#define TUPLE_H_INCLUDED_\n+\n+#include \"sequence.h\"\n+#include \n+\n+namespace py {\n+\n+\n+// added to make tuples mutable.\n+class tuple_member : public object\n+{\n+ tuple& _parent;\n+ int _ndx;\n+public:\n+ tuple_member(PyObject* obj, tuple& parent, int ndx);\n+ virtual ~tuple_member() {};\n+ tuple_member& operator=(const object& other);\n+ tuple_member& operator=(const tuple_member& other);\n+ tuple_member& operator=(int other);\n+ tuple_member& operator=(double other);\n+ tuple_member& operator=(const char* other);\n+ tuple_member& operator=(std::string other);\n+};\n+ \n+class tuple : public sequence\n+{\n+public:\n+ tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }\n+ tuple(const tuple& other) : sequence(other) { }\n+ tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }\n+ tuple(const list& list);\n+ virtual ~tuple() {};\n+\n+ virtual tuple& operator=(const tuple& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ /*virtual*/ tuple& operator=(const object& other) {\n+ GrabRef(other);\n+ _violentTypeCheck();\n+ return *this;\n+ };\n+ virtual void _violentTypeCheck() {\n+ if (!PyTuple_Check(_obj)) {\n+ GrabRef(0);\n+ Fail(PyExc_TypeError, \"Not a Python Tuple\");\n+ }\n+ };\n+ void set_item(int ndx, object& val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, val);\n+ val.disown(); //when using PyTuple_SetItem, he steals my reference\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+ \n+ // ej: additions\n+ void set_item(int ndx, int val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, double val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, char* val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ void set_item(int ndx, std::string val) {\n+ int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n+ if (rslt==-1)\n+ Fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+ tuple_member operator [] (int i) { // can't be virtual\n+ //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n+ PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount\n+ //Py_XINCREF(o);\n+ //if (o == 0)\n+ // Fail(PyExc_IndexError, \"index out of range\");\n+ return tuple_member(o, *this, i); // this increfs\n+ };\n+ // ej: end additions\n+ \n+};// class tuple\n+\n+} // namespace\n+\n+#endif // TUPLE_H_INCLUDED_\n", "added_lines": 96, "deleted_lines": 0, "source_code": "#if !defined(TUPLE_H_INCLUDED_)\n#define TUPLE_H_INCLUDED_\n\n#include \"sequence.h\"\n#include \n\nnamespace py {\n\n\n// added to make tuples mutable.\nclass tuple_member : public object\n{\n tuple& _parent;\n int _ndx;\npublic:\n tuple_member(PyObject* obj, tuple& parent, int ndx);\n virtual ~tuple_member() {};\n tuple_member& operator=(const object& other);\n tuple_member& operator=(const tuple_member& other);\n tuple_member& operator=(int other);\n tuple_member& operator=(double other);\n tuple_member& operator=(const char* other);\n tuple_member& operator=(std::string other);\n};\n \nclass tuple : public sequence\n{\npublic:\n tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }\n tuple(const tuple& other) : sequence(other) { }\n tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }\n tuple(const list& list);\n virtual ~tuple() {};\n\n virtual tuple& operator=(const tuple& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ tuple& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n void set_item(int ndx, object& val) {\n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disown(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n // ej: additions\n void set_item(int ndx, int val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, double val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, char* val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, std::string val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n tuple_member operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return tuple_member(o, *this, i); // this increfs\n };\n // ej: end additions\n \n};// class tuple\n\n} // namespace\n\n#endif // TUPLE_H_INCLUDED_\n", "source_code_before": null, "methods": [ { "name": "py::tuple_member::~tuple_member", "long_name": "py::tuple_member::~tuple_member()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( int sz = 0)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( const tuple & other)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( PyObject * obj)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::~tuple", "long_name": "py::tuple::~tuple()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const tuple & other)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const object & other)", "filename": "tuple.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::_violentTypeCheck", "long_name": "py::tuple::_violentTypeCheck()", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , object & val)", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , int val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , double val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 64, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , char * val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 70, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , std :: string val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::operator [ ]", "long_name": "py::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "py::tuple::operator [ ]", "long_name": "py::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( PyObject * obj)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::_violentTypeCheck", "long_name": "py::tuple::_violentTypeCheck()", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , std :: string val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple_member::~tuple_member", "long_name": "py::tuple_member::~tuple_member()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , char * val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 70, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::~tuple", "long_name": "py::tuple::~tuple()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const object & other)", "filename": "tuple.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( const tuple & other)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , double val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 64, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const tuple & other)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( int sz = 0)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , object & val)", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , int val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 72, "complexity": 20, "token_count": 514, "diff_parsed": { "added": [ "#if !defined(TUPLE_H_INCLUDED_)", "#define TUPLE_H_INCLUDED_", "", "#include \"sequence.h\"", "#include ", "", "namespace py {", "", "", "// added to make tuples mutable.", "class tuple_member : public object", "{", " tuple& _parent;", " int _ndx;", "public:", " tuple_member(PyObject* obj, tuple& parent, int ndx);", " virtual ~tuple_member() {};", " tuple_member& operator=(const object& other);", " tuple_member& operator=(const tuple_member& other);", " tuple_member& operator=(int other);", " tuple_member& operator=(double other);", " tuple_member& operator=(const char* other);", " tuple_member& operator=(std::string other);", "};", "", "class tuple : public sequence", "{", "public:", " tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }", " tuple(const tuple& other) : sequence(other) { }", " tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }", " tuple(const list& list);", " virtual ~tuple() {};", "", " virtual tuple& operator=(const tuple& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ tuple& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyTuple_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python Tuple\");", " }", " };", " void set_item(int ndx, object& val) {", " int rslt = PyTuple_SetItem(_obj, ndx, val);", " val.disown(); //when using PyTuple_SetItem, he steals my reference", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " // ej: additions", " void set_item(int ndx, int val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, double val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, char* val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, std::string val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " tuple_member operator [] (int i) { // can't be virtual", " //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid", " PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount", " //Py_XINCREF(o);", " //if (o == 0)", " // Fail(PyExc_IndexError, \"index out of range\");", " return tuple_member(o, *this, i); // this increfs", " };", " // ej: end additions", "", "};// class tuple", "", "} // namespace", "", "#endif // TUPLE_H_INCLUDED_" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/scxx/weave_imp.cpp", "filename": "weave_imp.cpp", "extension": "cpp", "change_type": "ADD", "diff": "@@ -0,0 +1,273 @@\n+/******************************************** \n+ copyright 1999 McMillan Enterprises, Inc.\n+ www.mcmillan-inc.com\n+*********************************************/\n+#include \"sequence.h\"\n+#include \"list.h\"\n+#include \"tuple.h\"\n+#include \"str.h\"\n+#include \"dict.h\"\n+#include \"callable.h\"\n+#include \"number.h\"\n+\n+using namespace py;\n+ \n+//---------------------------------------------------------------------------\n+// object\n+//---------------------------------------------------------------------------\n+\n+// incref new owner, and decref old owner, and adjust to new owner\n+void object::GrabRef(PyObject* newObj)\n+{\n+ // be careful to incref before decref if old is same as new\n+ Py_XINCREF(newObj);\n+ Py_XDECREF(_own);\n+ _own = _obj = newObj;\n+}\n+\n+//---------------------------------------------------------------------------\n+// sequence\n+//---------------------------------------------------------------------------\n+\n+bool sequence::in(int value) {\n+ object val = number(value);\n+ return in(val);\n+};\n+ \n+bool sequence::in(double value) {\n+ object val = number(value);\n+ return in(val);\n+};\n+\n+bool sequence::in(char* value) {\n+ object val = str(value);\n+ return in(val);\n+};\n+\n+bool sequence::in(std::string value) {\n+ object val = str(value.c_str());\n+ return in(val);\n+};\n+ \n+int sequence::count(int value) const {\n+ number val = number(value);\n+ return count(val);\n+};\n+\n+int sequence::count(double value) const {\n+ number val = number(value);\n+ return count(val);\n+};\n+\n+int sequence::count(char* value) const {\n+ str val = str(value);\n+ return count(val);\n+};\n+\n+int sequence::count(std::string value) const {\n+ str val = str(value.c_str());\n+ return count(val);\n+};\n+\n+int sequence::index(int value) const {\n+ number val = number(value);\n+ return index(val);\n+};\n+\n+int sequence::index(double value) const {\n+ number val = number(value);\n+ return index(val);\n+};\n+int sequence::index(char* value) const {\n+ str val = str(value);\n+ return index(val);\n+};\n+\n+int sequence::index(std::string value) const {\n+ str val = str(value.c_str());\n+ return index(val);\n+};\n+\n+//---------------------------------------------------------------------------\n+// tuple\n+//---------------------------------------------------------------------------\n+\n+tuple::tuple(const list& lst)\n+ : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n+\n+//---------------------------------------------------------------------------\n+// tuple_member\n+//---------------------------------------------------------------------------\n+\n+tuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n+ : object(obj), _parent(parent), _ndx(ndx) { }\n+\n+tuple_member& tuple_member::operator=(const object& other) {\n+ GrabRef(other);\n+ //Py_XINCREF(_obj); // this one is for set_item to steal\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+tuple_member& tuple_member::operator=(const tuple_member& other) {\n+ GrabRef(other);\n+ //Py_XINCREF(_obj); // this one is for set_item to steal\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+tuple_member& tuple_member::operator=(int other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+tuple_member& tuple_member::operator=(double other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+tuple_member& tuple_member::operator=(const char* other) {\n+ GrabRef(str(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+tuple_member& tuple_member::operator=(std::string other) {\n+ GrabRef(str(other.c_str()));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+//---------------------------------------------------------------------------\n+// list\n+//---------------------------------------------------------------------------\n+ \n+list& list::insert(int ndx, int other) {\n+ number oth = number(other);\n+ return insert(ndx, oth);\n+};\n+\n+list& list::insert(int ndx, double other) {\n+ number oth = number(other);\n+ return insert(ndx, oth);\n+};\n+\n+list& list::insert(int ndx, char* other) {\n+ str oth = str(other);\n+ return insert(ndx, oth);\n+};\n+\n+list& list::insert(int ndx, std::string other) {\n+ str oth = str(other.c_str());\n+ return insert(ndx, oth);\n+};\n+\n+//---------------------------------------------------------------------------\n+// list_member\n+//---------------------------------------------------------------------------\n+\n+list_member::list_member(PyObject* obj, list& parent, int ndx) \n+ : object(obj), _parent(parent), _ndx(ndx) { }\n+\n+list_member& list_member::operator=(const object& other) {\n+ GrabRef(other);\n+ //Py_XINCREF(_obj); // this one is for set_item to steal\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+list_member& list_member::operator=(const list_member& other) {\n+ GrabRef(other);\n+ //Py_XINCREF(_obj); // this one is for set_item to steal\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+list_member& list_member::operator=(int other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+list_member& list_member::operator=(double other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+list_member& list_member::operator=(const char* other) {\n+ GrabRef(str(other));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+list_member& list_member::operator=(std::string other) {\n+ GrabRef(str(other.c_str()));\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+}\n+\n+//---------------------------------------------------------------------------\n+// dict_member\n+//---------------------------------------------------------------------------\n+\n+dict_member& dict_member::operator=(const object& other) {\n+ GrabRef(other);\n+ _parent.set_item(_key, *this);\n+ return *this;\n+}\n+\n+dict_member& dict_member::operator=(int other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_key, *this);\n+ return *this;\n+}\n+\n+dict_member& dict_member::operator=(double other) {\n+ GrabRef(number(other));\n+ _parent.set_item(_key, *this);\n+ return *this;\n+}\n+\n+dict_member& dict_member::operator=(const char* other) {\n+ GrabRef(str(other));\n+ _parent.set_item(_key, *this);\n+ return *this;\n+}\n+\n+dict_member& dict_member::operator=(std::string other) {\n+ GrabRef(str(other.c_str()));\n+ _parent.set_item(_key, *this);\n+ return *this;\n+}\n+\n+//---------------------------------------------------------------------------\n+// callable\n+//---------------------------------------------------------------------------\n+\n+object callable::call() const {\n+ static tuple _empty;\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return rslt;\n+}\n+object callable::call(tuple& args) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return rslt;\n+}\n+object callable::call(tuple& args, dict& kws) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n+ if (rslt == 0)\n+ throw 1;\n+ return rslt;\n+}\n+\n+void py::Fail(PyObject* exc, const char* msg)\n+{\n+ PyErr_SetString(exc, msg);\n+ throw 1;\n+}\n\\ No newline at end of file\n", "added_lines": 273, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "source_code_before": null, "methods": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 37, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 47, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 52, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 81, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 146, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 156, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 161, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 170, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 187, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 199, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 205, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 221, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 249, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 256, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 262, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 269, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 269, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 37, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 256, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 262, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 187, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 52, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 205, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 221, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 81, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 161, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 47, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 199, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 156, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 170, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 146, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 249, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 193, "complexity": 44, "token_count": 1335, "diff_parsed": { "added": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#include \"sequence.h\"", "#include \"list.h\"", "#include \"tuple.h\"", "#include \"str.h\"", "#include \"dict.h\"", "#include \"callable.h\"", "#include \"number.h\"", "", "using namespace py;", "", "//---------------------------------------------------------------------------", "// object", "//---------------------------------------------------------------------------", "", "// incref new owner, and decref old owner, and adjust to new owner", "void object::GrabRef(PyObject* newObj)", "{", " // be careful to incref before decref if old is same as new", " Py_XINCREF(newObj);", " Py_XDECREF(_own);", " _own = _obj = newObj;", "}", "", "//---------------------------------------------------------------------------", "// sequence", "//---------------------------------------------------------------------------", "", "bool sequence::in(int value) {", " object val = number(value);", " return in(val);", "};", "", "bool sequence::in(double value) {", " object val = number(value);", " return in(val);", "};", "", "bool sequence::in(char* value) {", " object val = str(value);", " return in(val);", "};", "", "bool sequence::in(std::string value) {", " object val = str(value.c_str());", " return in(val);", "};", "", "int sequence::count(int value) const {", " number val = number(value);", " return count(val);", "};", "", "int sequence::count(double value) const {", " number val = number(value);", " return count(val);", "};", "", "int sequence::count(char* value) const {", " str val = str(value);", " return count(val);", "};", "", "int sequence::count(std::string value) const {", " str val = str(value.c_str());", " return count(val);", "};", "", "int sequence::index(int value) const {", " number val = number(value);", " return index(val);", "};", "", "int sequence::index(double value) const {", " number val = number(value);", " return index(val);", "};", "int sequence::index(char* value) const {", " str val = str(value);", " return index(val);", "};", "", "int sequence::index(std::string value) const {", " str val = str(value.c_str());", " return index(val);", "};", "", "//---------------------------------------------------------------------------", "// tuple", "//---------------------------------------------------------------------------", "", "tuple::tuple(const list& lst)", " : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }", "", "//---------------------------------------------------------------------------", "// tuple_member", "//---------------------------------------------------------------------------", "", "tuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx)", " : object(obj), _parent(parent), _ndx(ndx) { }", "", "tuple_member& tuple_member::operator=(const object& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(const tuple_member& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "//---------------------------------------------------------------------------", "// list", "//---------------------------------------------------------------------------", "", "list& list::insert(int ndx, int other) {", " number oth = number(other);", " return insert(ndx, oth);", "};", "", "list& list::insert(int ndx, double other) {", " number oth = number(other);", " return insert(ndx, oth);", "};", "", "list& list::insert(int ndx, char* other) {", " str oth = str(other);", " return insert(ndx, oth);", "};", "", "list& list::insert(int ndx, std::string other) {", " str oth = str(other.c_str());", " return insert(ndx, oth);", "};", "", "//---------------------------------------------------------------------------", "// list_member", "//---------------------------------------------------------------------------", "", "list_member::list_member(PyObject* obj, list& parent, int ndx)", " : object(obj), _parent(parent), _ndx(ndx) { }", "", "list_member& list_member::operator=(const object& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(const list_member& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "//---------------------------------------------------------------------------", "// dict_member", "//---------------------------------------------------------------------------", "", "dict_member& dict_member::operator=(const object& other) {", " GrabRef(other);", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "//---------------------------------------------------------------------------", "// callable", "//---------------------------------------------------------------------------", "", "object callable::call() const {", " static tuple _empty;", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "object callable::call(tuple& args) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "object callable::call(tuple& args, dict& kws) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "", "void py::Fail(PyObject* exc, const char* msg)", "{", " PyErr_SetString(exc, msg);", " throw 1;", "}" ], "deleted": [] } } ] }, { "hash": "b986d7aaf86ad103ee49d325b85732dcfbe3a19e", "msg": "made changes necessary to .py files to use the new modified version of scxx.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-23T08:08:49+00:00", "author_timezone": 0, "committer_date": "2002-09-23T08:08:49+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ccc5a06bd857e3e6de81b1a18b3959e3ceacf4aa" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 65, "insertions": 73, "lines": 138, "files": 6, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/c_spec.py", "new_path": "weave/c_spec.py", "filename": "c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -184,27 +184,6 @@ def init_info(self):\n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n \n-#----------------------------------------------------------------------------\n-# Instance Converter\n-#----------------------------------------------------------------------------\n-class instance_converter(common_base_converter):\n- def init_info(self):\n- common_base_converter.init_info(self)\n- self.type_name = 'instance'\n- self.check_func = 'PyInstance_Check' \n- self.matching_types = [InstanceType]\n-\n-#----------------------------------------------------------------------------\n-# Catchall Converter\n-#----------------------------------------------------------------------------\n-class catchall_converter(common_base_converter):\n- def init_info(self):\n- common_base_converter.init_info(self)\n- self.type_name = 'catchall'\n- self.check_func = '' \n- def type_match(self,value):\n- return 1\n-\n #----------------------------------------------------------------------------\n # String Converter\n #----------------------------------------------------------------------------\n@@ -357,27 +336,26 @@ def init_info(self):\n #----------------------------------------------------------------------------\n import os, c_spec # yes, I import myself to find out my __file__ location.\n local_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \n-scxx_dir = os.path.join(local_dir,'scxx')\n+scxx_dir = os.path.join(local_dir,'scxx2')\n \n class scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n- self.headers = ['\"scxx/PWOBase.h\"','\"scxx/PWOSequence.h\"',\n- '\"scxx/PWOCallable.h\"','\"scxx/PWOMapping.h\"',\n- '\"scxx/PWOSequence.h\"','\"scxx/PWOMSequence.h\"',\n- '\"scxx/PWONumber.h\"','']\n+ self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n+ '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n+ '\"scxx/callable.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n- self.sources = [os.path.join(scxx_dir,'PWOImp.cpp'),]\n+ self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n \n class list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n- self.c_type = 'PWOList'\n- self.to_c_return = 'PWOList(py_obj)'\n+ self.c_type = 'py::list'\n+ self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n- # ref counting handled by PWOList\n+ # ref counting handled by py::list\n self.use_ref_count = 0\n \n class tuple_converter(scxx_converter):\n@@ -385,23 +363,51 @@ def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n- self.c_type = 'PWOTuple'\n- self.to_c_return = 'PWOTuple(py_obj)'\n+ self.c_type = 'py::tuple'\n+ self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n- # ref counting handled by PWOTuple\n+ # ref counting handled by py::tuple\n self.use_ref_count = 0\n \n class dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n- self.support_code.append(\"#define PWODict PWOMapping\")\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n- self.c_type = 'PWODict'\n- self.to_c_return = 'PWODict(py_obj)'\n+ self.c_type = 'py::dict'\n+ self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n- # ref counting handled by PWODict\n+ # ref counting handled by py::dict\n+ self.use_ref_count = 0\n+\n+#----------------------------------------------------------------------------\n+# Instance Converter\n+#----------------------------------------------------------------------------\n+class instance_converter(scxx_converter):\n+ def init_info(self):\n+ scxx_converter.init_info(self)\n+ self.type_name = 'instance'\n+ self.check_func = 'PyInstance_Check' \n+ self.c_type = 'py::object'\n+ self.to_c_return = 'py::object(py_obj)'\n+ self.matching_types = [InstanceType]\n+ # ref counting handled by py::object\n+ self.use_ref_count = 0\n+\n+#----------------------------------------------------------------------------\n+# Catchall Converter\n+#----------------------------------------------------------------------------\n+class catchall_converter(scxx_converter):\n+ def init_info(self):\n+ scxx_converter.init_info(self)\n+ self.type_name = 'catchall'\n+ self.check_func = '' \n+ self.c_type = 'py::object'\n+ self.to_c_return = 'py::object(py_obj)'\n+ # ref counting handled by py::object\n self.use_ref_count = 0\n+ def type_match(self,value):\n+ return 1\n \n #----------------------------------------------------------------------------\n # Callable Converter\n@@ -413,9 +419,9 @@ def init_info(self):\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n- self.c_type = 'PWOCallable'\n- self.to_c_return = 'PWOCallable(py_obj)'\n- # ref counting handled by PWOCallable\n+ self.c_type = 'py::callable'\n+ self.to_c_return = 'py::callable(py_obj)'\n+ # ref counting handled by py::callable\n self.use_ref_count = 0\n \n def test(level=10):\n", "added_lines": 46, "deleted_lines": 40, "source_code": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx2')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '\"scxx/callable.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\n#----------------------------------------------------------------------------\n# Callable Converter\n#----------------------------------------------------------------------------\nclass callable_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'callable'\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n self.c_type = 'py::callable'\n self.to_c_return = 'py::callable(py_obj)'\n # ref counting handled by py::callable\n self.use_ref_count = 0\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.matching_types = [InstanceType]\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#----------------------------------------------------------------------------\nclass catchall_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n def type_match(self,value):\n return 1\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/PWOBase.h\"','\"scxx/PWOSequence.h\"',\n '\"scxx/PWOCallable.h\"','\"scxx/PWOMapping.h\"',\n '\"scxx/PWOSequence.h\"','\"scxx/PWOMSequence.h\"',\n '\"scxx/PWONumber.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'PWOImp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'PWOList'\n self.to_c_return = 'PWOList(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by PWOList\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'PWOTuple'\n self.to_c_return = 'PWOTuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by PWOTuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.support_code.append(\"#define PWODict PWOMapping\")\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'PWODict'\n self.to_c_return = 'PWODict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by PWODict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Callable Converter\n#----------------------------------------------------------------------------\nclass callable_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'callable'\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n self.c_type = 'PWOCallable'\n self.to_c_return = 'PWOCallable(py_obj)'\n # ref counting handled by PWOCallable\n self.use_ref_count = 0\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 401, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 416, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 427, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 191, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 201, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 205, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 220, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 234, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 249, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 258, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 307, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 314, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 323, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 333, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 343, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 363, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 384, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 395, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 410, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 421, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 425, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 324, "complexity": 48, "token_count": 1656, "diff_parsed": { "added": [ "scxx_dir = os.path.join(local_dir,'scxx2')", " self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',", " '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',", " '\"scxx/callable.h\"','']", " self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]", " self.c_type = 'py::list'", " self.to_c_return = 'py::list(py_obj)'", " # ref counting handled by py::list", " self.c_type = 'py::tuple'", " self.to_c_return = 'py::tuple(py_obj)'", " # ref counting handled by py::tuple", " self.c_type = 'py::dict'", " self.to_c_return = 'py::dict(py_obj)'", " # ref counting handled by py::dict", " self.use_ref_count = 0", "", "#----------------------------------------------------------------------------", "# Instance Converter", "#----------------------------------------------------------------------------", "class instance_converter(scxx_converter):", " def init_info(self):", " scxx_converter.init_info(self)", " self.type_name = 'instance'", " self.check_func = 'PyInstance_Check'", " self.c_type = 'py::object'", " self.to_c_return = 'py::object(py_obj)'", " self.matching_types = [InstanceType]", " # ref counting handled by py::object", " self.use_ref_count = 0", "", "#----------------------------------------------------------------------------", "# Catchall Converter", "#----------------------------------------------------------------------------", "class catchall_converter(scxx_converter):", " def init_info(self):", " scxx_converter.init_info(self)", " self.type_name = 'catchall'", " self.check_func = ''", " self.c_type = 'py::object'", " self.to_c_return = 'py::object(py_obj)'", " # ref counting handled by py::object", " def type_match(self,value):", " return 1", " self.c_type = 'py::callable'", " self.to_c_return = 'py::callable(py_obj)'", " # ref counting handled by py::callable" ], "deleted": [ "#----------------------------------------------------------------------------", "# Instance Converter", "#----------------------------------------------------------------------------", "class instance_converter(common_base_converter):", " def init_info(self):", " common_base_converter.init_info(self)", " self.type_name = 'instance'", " self.check_func = 'PyInstance_Check'", " self.matching_types = [InstanceType]", "", "#----------------------------------------------------------------------------", "# Catchall Converter", "#----------------------------------------------------------------------------", "class catchall_converter(common_base_converter):", " def init_info(self):", " common_base_converter.init_info(self)", " self.type_name = 'catchall'", " self.check_func = ''", " def type_match(self,value):", " return 1", "", "scxx_dir = os.path.join(local_dir,'scxx')", " self.headers = ['\"scxx/PWOBase.h\"','\"scxx/PWOSequence.h\"',", " '\"scxx/PWOCallable.h\"','\"scxx/PWOMapping.h\"',", " '\"scxx/PWOSequence.h\"','\"scxx/PWOMSequence.h\"',", " '\"scxx/PWONumber.h\"','']", " self.sources = [os.path.join(scxx_dir,'PWOImp.cpp'),]", " self.c_type = 'PWOList'", " self.to_c_return = 'PWOList(py_obj)'", " # ref counting handled by PWOList", " self.c_type = 'PWOTuple'", " self.to_c_return = 'PWOTuple(py_obj)'", " # ref counting handled by PWOTuple", " self.support_code.append(\"#define PWODict PWOMapping\")", " self.c_type = 'PWODict'", " self.to_c_return = 'PWODict(py_obj)'", " # ref counting handled by PWODict", " self.c_type = 'PWOCallable'", " self.to_c_return = 'PWOCallable(py_obj)'", " # ref counting handled by PWOCallable" ] } }, { "old_path": "weave/common_info.py", "new_path": "weave/common_info.py", "filename": "common_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -11,7 +11,9 @@\n \"\"\"\n \n // global None value for use in functions.\n-PWOBase PWONone = PWOBase(Py_None);\n+namespace py {\n+object None = object(Py_None);\n+}\n \n char* find_type(PyObject* py_obj)\n {\n", "added_lines": 3, "deleted_lines": 1, "source_code": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\n// global None value for use in functions.\nnamespace py {\nobject None = object(Py_None);\n}\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "source_code_before": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\n// global None value for use in functions.\nPWOBase PWONone = PWOBase(Py_None);\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 106, "complexity": 0, "token_count": 115, "diff_parsed": { "added": [ "namespace py {", "object None = object(Py_None);", "}" ], "deleted": [ "PWOBase PWONone = PWOBase(Py_None);" ] } }, { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -115,7 +115,7 @@ def function_code(self):\n \n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n- \" PWODict local_dict = PWODict(py_local_dict); \\n\" + \\\n+ \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'PyObject *return_val = NULL;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = NULL; \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' Py_INCREF(Py_None); \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val; \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n \n file = self.generate_file(location=location)\n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'PyObject *return_val = NULL;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" PWODict local_dict = PWODict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = NULL; \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' Py_INCREF(Py_None); \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val; \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n \n file = self.generate_file(location=location)\n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 37, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 110, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 166, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 184, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 194, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 209, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 219, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 233, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 238, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 248, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 270, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 278, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 22, "complexity": 4, "token_count": 206, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 288, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 332, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "module_string", "module_file" ], "start_line": 336, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 342, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 379, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 408, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 422, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 426, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 37, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 110, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 166, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 184, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 194, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 209, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 219, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 233, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 238, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 248, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 270, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 278, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 22, "complexity": 4, "token_count": 206, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 288, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 332, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "module_string", "module_file" ], "start_line": 336, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 342, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 379, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 408, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 422, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 426, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 37, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 110, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 } ], "nloc": 316, "complexity": 75, "token_count": 2018, "diff_parsed": { "added": [ " \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\" ], "deleted": [ " \" PWODict local_dict = PWODict(py_local_dict); \\n\" + \\" ] } }, { "old_path": "weave/setup_weave.py", "new_path": "weave/setup_weave.py", "filename": "setup_weave.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -12,8 +12,8 @@ def configuration(parent_package=''):\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n- scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n- install_path = os.path.join(parent_path,'weave','scxx')\n+ scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))\n+ install_path = os.path.join(parent_path,'weave','scxx2')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n local_path = get_path(__name__)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx2')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n local_path = get_path(__name__)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "nloc": 40, "complexity": 1, "token_count": 438, "diff_parsed": { "added": [ " scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))", " install_path = os.path.join(parent_path,'weave','scxx2')" ], "deleted": [ " scxx_files = glob(os.path.join(local_path,'scxx','*.*'))", " install_path = os.path.join(parent_path,'weave','scxx')" ] } }, { "old_path": "weave/tests/test_c_spec.py", "new_path": "weave/tests/test_c_spec.py", "filename": "test_c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -272,10 +272,10 @@ def check_call_function(self):\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n- PWOTuple args(2);\n- args.setItem(0,search_str);\n- args.setItem(1,sub_str);\n- return_val = PyObject_CallObject(func,args);\n+ py::tuple args(2);\n+ args[0] = search_str;\n+ args[1] = sub_str;\n+ return_val = func.call(args).disown();\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n@@ -367,7 +367,7 @@ def check_var_in(self):\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n- code = 'a=PWOList();'\n+ code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n@@ -391,9 +391,9 @@ def check_return(self):\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n- a=PWOList();\n+ a=py::list();\n a.append(\"hello\");\n- return_val = a.disOwn();\n+ return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n@@ -409,7 +409,7 @@ def check_speed(self):\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n- PWONumber v = PWONumber();\n+ py::number v = py::number();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n@@ -480,7 +480,7 @@ def check_var_in(self):\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n- code = 'a=PWOTuple();'\n+ code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n@@ -504,10 +504,10 @@ def check_return(self):\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n- a=PWOTuple(2);\n- a.setItem(0,\"hello\");\n- a.setItem(1,PWONone);\n- return_val = a.disOwn();\n+ a=py::tuple(2);\n+ a[0] = \"hello\";\n+ a.set_item(1,py::None);\n+ return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n@@ -532,7 +532,7 @@ def check_var_in(self):\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n- code = 'a=PWODict();' # This just checks to make sure the type is correct\n+ code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n@@ -556,9 +556,9 @@ def check_return(self):\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n- a=PWODict();\n- a[\"hello\"] = PWONumber(5);\n- return_val = a.disOwn();\n+ a=py::dict();\n+ a[\"hello\"] = 5;\n+ return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n", "added_lines": 17, "deleted_lines": 17, "source_code": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args).disown();\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n py::number v = py::number();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n PWOTuple args(2);\n args.setItem(0,search_str);\n args.setItem(1,sub_str);\n return_val = PyObject_CallObject(func,args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=PWOList();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=PWOList();\n a.append(\"hello\");\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n PWONumber v = PWONumber();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=PWOTuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=PWOTuple(2);\n a.setItem(0,\"hello\");\n a.setItem(1,PWONone);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=PWODict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=PWODict();\n a[\"hello\"] = PWONumber(5);\n return_val = a.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 287, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 308, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 311, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 314, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 362, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 365, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 388, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 470, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 478, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 501, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 522, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 527, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 530, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 553, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 651, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 662, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 672, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 287, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 308, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 311, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 314, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 362, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 365, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 388, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 470, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 478, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 501, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 522, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 527, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 530, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 553, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 651, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 662, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 672, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 365, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 388, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 648, "complexity": 79, "token_count": 3824, "diff_parsed": { "added": [ " py::tuple args(2);", " args[0] = search_str;", " args[1] = sub_str;", " return_val = func.call(args).disown();", " code = 'a=py::list();'", " a=py::list();", " return_val = a.disown();", " py::number v = py::number();", " code = 'a=py::tuple();'", " a=py::tuple(2);", " a[0] = \"hello\";", " a.set_item(1,py::None);", " return_val = a.disown();", " code = 'a=py::dict();' # This just checks to make sure the type is correct", " a=py::dict();", " a[\"hello\"] = 5;", " return_val = a.disown();" ], "deleted": [ " PWOTuple args(2);", " args.setItem(0,search_str);", " args.setItem(1,sub_str);", " return_val = PyObject_CallObject(func,args);", " code = 'a=PWOList();'", " a=PWOList();", " return_val = a.disOwn();", " PWONumber v = PWONumber();", " code = 'a=PWOTuple();'", " a=PWOTuple(2);", " a.setItem(0,\"hello\");", " a.setItem(1,PWONone);", " return_val = a.disOwn();", " code = 'a=PWODict();' # This just checks to make sure the type is correct", " a=PWODict();", " a[\"hello\"] = PWONumber(5);", " return_val = a.disOwn();" ] } }, { "old_path": "weave/tests/test_ext_tools.py", "new_path": "weave/tests/test_ext_tools.py", "filename": "test_ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -84,10 +84,10 @@ def check_return_tuple(self):\n code = \"\"\"\n int b;\n b = a + 1;\n- PWOTuple returned(2);\n- returned.setItem(0,PWONumber(a));\n- returned.setItem(1,PWONumber(b));\n- return_val = returned.disOwn();\n+ py::tuple returned(2);\n+ returned[0] = a;\n+ returned[1] = b;\n+ return_val = returned.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n", "added_lines": 4, "deleted_lines": 4, "source_code": "import unittest\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\ntry:\n from standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n import c_spec\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n if level >= 5: \n suites.append( unittest.makeSuite(test_ext_module,'check_'))\n suites.append( unittest.makeSuite(test_ext_function,'check_')) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\ntry:\n from standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n PWOTuple returned(2);\n returned.setItem(0,PWONumber(a));\n returned.setItem(1,PWONumber(b));\n return_val = returned.disOwn();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n import c_spec\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n if level >= 5: \n suites.append( unittest.makeSuite(test_ext_module,'check_'))\n suites.append( unittest.makeSuite(test_ext_function,'check_')) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 101, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 21, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 113, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 101, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 21, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 113, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 126, "complexity": 13, "token_count": 740, "diff_parsed": { "added": [ " py::tuple returned(2);", " returned[0] = a;", " returned[1] = b;", " return_val = returned.disown();" ], "deleted": [ " PWOTuple returned(2);", " returned.setItem(0,PWONumber(a));", " returned.setItem(1,PWONumber(b));", " return_val = returned.disOwn();" ] } } ] }, { "hash": "996d34f42c84e2d6cc5cabd4a715ee097e7aa2f6", "msg": "Enabled true jiffies for Mandrake linux", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-25T12:28:10+00:00", "author_timezone": 0, "committer_date": "2002-09-25T12:28:10+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b986d7aaf86ad103ee49d325b85732dcfbe3a19e" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -27,7 +27,7 @@ def get_package_path(testfile):\n return d1\n return os.path.dirname(d)\n \n-if sys.platform=='linux2':\n+if sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\ndef get_package_path(testfile):\n \"\"\" Return path to package directory first assuming that testfile\n satisfies the following tree structure:\n /build/lib.-\n //testfile\n If build directory does not exist, then return\n /..\n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return os.path.dirname(d)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i/build/lib.-\n //testfile\n If build directory does not exist, then return\n /..\n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return os.path.dirname(d)\n\nif sys.platform=='linux2':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py\n+\n+ Then the first existing path name from the following list\n+\n /build/lib.-\n- //testfile\n- If build directory does not exist, then return\n /..\n+\n+ is prepended to sys.path.\n+ The caller is responsible for removing this path by using\n+\n+ del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n+ from scipy_distutils.misc_util import get_frame\n+ f = get_frame(1)\n+ if f.f_locals['__name__']=='__main__':\n+ testfile = sys.argv[0]\n+ else:\n+ testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n- if os.path.isdir(d1):\n- return d1\n- return os.path.dirname(d)\n+ if not os.path.isdir(d1):\n+ d1 = os.path.dirname(d)\n+ sys.path.insert(0,d1)\n \n if sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n", "added_lines": 24, "deleted_lines": 7, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path():\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i/build/lib.-\n //testfile\n If build directory does not exist, then return\n /..\n \"\"\"\n from distutils.util import get_platform\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if os.path.isdir(d1):\n return d1\n return os.path.dirname(d)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py", "", " Then the first existing path name from the following list", "", "", " is prepended to sys.path.", " The caller is responsible for removing this path by using", "", " del sys.path[0]", " from scipy_distutils.misc_util import get_frame", " f = get_frame(1)", " if f.f_locals['__name__']=='__main__':", " testfile = sys.argv[0]", " else:", " testfile = f.f_locals['__file__']", " if not os.path.isdir(d1):", " d1 = os.path.dirname(d)", " sys.path.insert(0,d1)" ], "deleted": [ "def get_package_path(testfile):", " \"\"\" Return path to package directory first assuming that testfile", " //testfile", " If build directory does not exist, then return", " if os.path.isdir(d1):", " return d1", " return os.path.dirname(d)" ] } } ] }, { "hash": "51cbd9cb19d5b8086b59425a5ffe1fc7b7734392", "msg": "Giving a warning if older ATLAS is used (that eventually will result in import error about missing clapack_sgetri)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-25T15:54:31+00:00", "author_timezone": 0, "committer_date": "2002-09-25T15:54:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1f756d4c0b476a607eb67c2a84583506c85496aa" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 2, "insertions": 16, "lines": 18, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -442,7 +442,6 @@ def calc_info(self):\n return\n \n if h: dict_append(info,include_dirs=[h])\n- self.set_info(**info)\n \n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n@@ -457,8 +456,8 @@ def calc_info(self):\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n+ import warnings\n if sz <= 4000*1024:\n- import warnings\n message = \"\"\"\n *********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n@@ -469,6 +468,21 @@ def calc_info(self):\n *********************************************************************\n \"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n+ info['size_liblapack'] = sz\n+ flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n+ info['has_clapack_sgetri'] = not flag\n+ if flag:\n+ message = \"\"\"\n+*********************************************************************\n+ Using probably old ATLAS version (<3.3.??):\n+ nm %s | grep clapack_sgetri\n+ returned %s\n+ ATLAS update is recommended. See scipy/INSTALL.txt.\n+*********************************************************************\n+\"\"\" % (lapack_lib,flag)\n+ warnings.warn(message)\n+ self.set_info(**info)\n+\n \n class lapack_info(system_info):\n section = 'lapack'\n", "added_lines": 16, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n info['size_liblapack'] = sz\n flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n if sz <= 4000*1024:\n import warnings\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 54, "complexity": 11, "token_count": 285, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 41, "complexity": 10, "token_count": 244, "parameters": [ "self" ], "start_line": 426, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 477, "end_line": 488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 501, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 592, "end_line": 603, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 609, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 616, "end_line": 651, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 656, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 661, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 682, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 705, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 715, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 54, "complexity": 11, "token_count": 285, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 } ], "nloc": 650, "complexity": 124, "token_count": 3201, "diff_parsed": { "added": [ " import warnings", " info['size_liblapack'] = sz", " flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)", " info['has_clapack_sgetri'] = not flag", " if flag:", " message = \"\"\"", "*********************************************************************", " Using probably old ATLAS version (<3.3.??):", " nm %s | grep clapack_sgetri", " returned %s", " ATLAS update is recommended. See scipy/INSTALL.txt.", "*********************************************************************", "\"\"\" % (lapack_lib,flag)", " warnings.warn(message)", " self.set_info(**info)", "" ], "deleted": [ " self.set_info(**info)", " import warnings" ] } } ] }, { "hash": "1fb972c10a6717ac117c4a599ee91ba7d88557ac", "msg": "Fixed typo causing segfaults with Numeric<22.0.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-25T21:29:28+00:00", "author_timezone": 0, "committer_date": "2002-09-25T21:29:28+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "51cbd9cb19d5b8086b59425a5ffe1fc7b7734392" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumath_nounsigned.inc", "new_path": "scipy_base/fastumath_nounsigned.inc", "filename": "fastumath_nounsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -1233,7 +1233,7 @@ static void UBYTE_greater(char **args, int *dimensions, int *steps, void *func)\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n+\t*((unsigned char *)op)=*((unsigned char *)i1) > *((unsigned char *)i2);\n }\n }\n static void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n", "added_lines": 1, "deleted_lines": 1, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod;\n multiply_data[8] = (void *)c_prod;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n divide_safe_data[7] = (void *)c_quot;\n divide_safe_data[8] = (void *)c_quot;\n divide_safe_data[9] = (void *)PyNumber_Divide;\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow;\n power_data[8] = (void *)c_pow;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod;\n multiply_data[8] = (void *)c_prod;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n divide_safe_data[7] = (void *)c_quot;\n divide_safe_data[8] = (void *)c_quot;\n divide_safe_data[9] = (void *)PyNumber_Divide;\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow;\n power_data[8] = (void *)c_pow;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "\t*((unsigned char *)op)=*((unsigned char *)i1) > *((unsigned char *)i2);" ], "deleted": [ "\t*((long *)op)=*((unsigned char *)i1) > *((unsigned char *)i2);" ] } } ] }, { "hash": "d5ce0d2ab3abc535435b079d453562b087c768d3", "msg": "Disabled size_liblapack,has_clapack_sgetri bits.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-25T22:22:24+00:00", "author_timezone": 0, "committer_date": "2002-09-25T22:22:24+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1fb972c10a6717ac117c4a599ee91ba7d88557ac" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -468,9 +468,9 @@ def calc_info(self):\n *********************************************************************\n \"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n- info['size_liblapack'] = sz\n+ #info['size_liblapack'] = sz\n flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n- info['has_clapack_sgetri'] = not flag\n+ #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n *********************************************************************\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n info['size_liblapack'] = sz\n flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 272, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 54, "complexity": 11, "token_count": 285, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 272, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 } ], "nloc": 648, "complexity": 124, "token_count": 3188, "diff_parsed": { "added": [ " #info['size_liblapack'] = sz", " #info['has_clapack_sgetri'] = not flag" ], "deleted": [ " info['size_liblapack'] = sz", " info['has_clapack_sgetri'] = not flag" ] } } ] }, { "hash": "13f70d0bb397f2c6dadc620bcbf2b4e57d619506", "msg": "Disabled size_liblapack,has_clapack_sgetri bits.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-25T22:28:53+00:00", "author_timezone": 0, "committer_date": "2002-09-25T22:28:53+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d5ce0d2ab3abc535435b079d453562b087c768d3" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -469,7 +469,7 @@ def calc_info(self):\n \"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n- flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n+ flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 272, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 } ], "nloc": 648, "complexity": 124, "token_count": 3181, "diff_parsed": { "added": [ " flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)" ], "deleted": [ " flag = os.system('nm %s | grep clapack_sgetri '%lapack_lib)" ] } } ] }, { "hash": "23739c87020bb5b94544db0c157df091d807cae8", "msg": "rearrange failure message slightly and dump trailing whitespace", "author": { "name": "skip", "email": "skip@localhost" }, "committer": { "name": "skip", "email": "skip@localhost" }, "author_date": "2002-09-26T15:12:31+00:00", "author_timezone": 0, "committer_date": "2002-09-26T15:12:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "13f70d0bb397f2c6dadc620bcbf2b4e57d619506" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 26, "insertions": 25, "lines": 51, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -92,11 +92,11 @@ def remove_ignored_patterns(files,pattern):\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n- return good_files \n+ return good_files\n \n def remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n- \n+\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n@@ -106,13 +106,13 @@ def remove_ignored_files(original,ignored_files,cur_dir):\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n- #print 'ignored:', ignored_files \n+ #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n- \n+\n return good_files\n \n __all__.append('harvest_modules')\n@@ -131,18 +131,18 @@ def harvest_modules(package,ignore=None):\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n- \n+\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n- \n+\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n- base,ext = os.path.splitext(f) \n+ base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n@@ -150,8 +150,8 @@ def harvest_modules(package,ignore=None):\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n- output_exception() \n- \n+ output_exception()\n+\n return all_modules\n \n __all__.append('harvest_packages')\n@@ -169,7 +169,7 @@ def harvest_packages(package,ignore = None):\n \n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n- \n+\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n@@ -177,7 +177,7 @@ def harvest_packages(package,ignore = None):\n except:\n prefix = ''\n all_packages = []\n- for directory in all_files: \n+ for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n@@ -188,7 +188,7 @@ def harvest_packages(package,ignore = None):\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n- output_exception() \n+ output_exception()\n return all_packages\n \n __all__.append('harvest_modules_and_packages')\n@@ -203,8 +203,8 @@ def harvest_modules_and_packages(package,ignore=None):\n __all__.append('harvest_test_suites')\n def harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n- package -- the module to test. This is an actual module object \n- (not a string) \n+ package -- the module to test. This is an actual module object\n+ (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n@@ -219,21 +219,20 @@ def harvest_test_suites(package,ignore = None,level=10):\n try:\n suite = module.test_suite(level=level)\n if suite:\n- suites.append(suite) \n+ suites.append(suite)\n else:\n- msg = \" !! FAILURE without error - shouldn't happen\" + \\\n- module.__name__ \n- print msg\n+ print \" !! FAILURE without error - shouldn't happen\",\n+ print module.__name__\n except:\n- print ' !! FAILURE building test for ', module.__name__ \n+ print ' !! FAILURE building test for ', module.__name__\n print ' ',\n- output_exception() \n+ output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n- # in checking for modules, so we think is a module has \n+ # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n@@ -296,7 +295,7 @@ def module_test_suite(mod_name,mod_file,level=10):\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n- # output_exception() \n+ # output_exception()\n \n \n # Utility function to facilitate testing.\n@@ -339,7 +338,7 @@ def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n- Approximately equal is defined as the number of significant digits \n+ Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n@@ -356,7 +355,7 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n + 'DESIRED: ' + str(desired) \\\n + '\\nACTUAL: ' + str(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n- \n+\n \n __all__.append('assert_array_equal')\n def assert_array_equal(x,y,err_msg=''):\n@@ -385,7 +384,7 @@ def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n- \n+\n __all__.append('rand')\n def rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n@@ -396,7 +395,7 @@ def rand(*args):\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n- return results \n+ return results\n \n def output_exception():\n try:\n", "added_lines": 25, "deleted_lines": 26, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path():\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '\"scxx/callable.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\n#----------------------------------------------------------------------------\n# Callable Converter\n#----------------------------------------------------------------------------\nclass callable_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'callable'\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n self.c_type = 'py::callable'\n self.to_c_return = 'py::callable(py_obj)'\n # ref counting handled by py::callable\n self.use_ref_count = 0\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx2')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '\"scxx/callable.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\n#----------------------------------------------------------------------------\n# Callable Converter\n#----------------------------------------------------------------------------\nclass callable_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'callable'\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n self.c_type = 'py::callable'\n self.to_c_return = 'py::callable(py_obj)'\n # ref counting handled by py::callable\n self.use_ref_count = 0\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 401, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 416, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 427, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 401, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 416, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 427, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 324, "complexity": 48, "token_count": 1656, "diff_parsed": { "added": [ "scxx_dir = os.path.join(local_dir,'scxx')", " print x.cleanup_code()" ], "deleted": [ "scxx_dir = os.path.join(local_dir,'scxx2')", " print x.cleanup_code()" ] } } ] }, { "hash": "79486d23803b7be8f2510f6d2f5a70425f314f2b", "msg": "added support for method calls on objects using mcall:\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\nmoved callable object support directly into object using the call() method.\n\nobject is pretty well fleshed out now. It needs more unit tests in the\ntest_scxx test suite. I'm not sure attr() handles ref counts correctly.\n\nAlso, I would like to see if operator[] can be optimized for a[i] = b[i]\ntype operations. It is currently much slower than using the C api and\nalso slower than pure python.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-28T08:45:07+00:00", "author_timezone": 0, "committer_date": "2002-09-28T08:45:07+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ced697210cb415151dfd488fc72cd8eff9434bd5" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 11, "insertions": 90, "lines": 101, "files": 3, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.7962962962962963, "modified_files": [ { "old_path": "weave/scxx/notes.txt", "new_path": "weave/scxx/notes.txt", "filename": "notes.txt", "extension": "txt", "change_type": "MODIFY", "diff": "@@ -10,13 +10,18 @@ chaco\n \n weave\n \n-Proposed changes:\n+Proposed changes to weave:\n \n+* change return_val to a py::object\n+ This could remove almost all of the need of handling PyObject*.\n+* document changes. \n+* review directory structure.\n+* outline method of aggregating functions into a single file.\n+\n+EVERYTHING BELOW HERE IS DONE.\n * all classes moved to py:: namespace\n * made tuples mutable with indexing notation. (handy in weave)\n * converted camel case names (setItem -> set_item)\n-\n-\n * change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n", "added_lines": 8, "deleted_lines": 3, "source_code": "base package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nProposed changes to weave:\n\n* change return_val to a py::object\n This could remove almost all of the need of handling PyObject*.\n* document changes. \n* review directory structure.\n* outline method of aggregating functions into a single file.\n\nEVERYTHING BELOW HERE IS DONE.\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "source_code_before": "base package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nProposed changes:\n\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n\n\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "Proposed changes to weave:", "* change return_val to a py::object", " This could remove almost all of the need of handling PyObject*.", "* document changes.", "* review directory structure.", "* outline method of aggregating functions into a single file.", "", "EVERYTHING BELOW HERE IS DONE." ], "deleted": [ "Proposed changes:", "", "" ] } }, { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -10,10 +10,15 @@\n \n #include \n #include \n+#include \n \n namespace py {\n \n void Fail(PyObject*, const char* msg);\n+\n+// used in method call specification.\n+class tuple;\n+class dict;\n \n class object \n {\n@@ -55,13 +60,18 @@ public:\n };\n \n // Need to change return type?\n- PyObject* attr(const char* nm) const {\n- return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n- };\n- PyObject* attr(const object& nm) const {\n- return LoseRef(PyObject_GetAttr(_obj, nm));\n- };\n- \n+ object attr(const char* nm) const {\n+ // do we want the LoseRef\n+ return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));\n+ };\n+ object attr(std::string nm) const {\n+ // do we want the LoseRef\n+ return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));\n+ };\n+ object attr(const object& nm) const {\n+ // do we want the LoseRef\n+ return object(LoseRef(PyObject_GetAttr(_obj, nm)));\n+ }; \n \n int set_attr(const char* nm, object& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n@@ -69,7 +79,25 @@ public:\n int set_attr(PyObject* nm, object& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n- \n+\n+ object mcall(const char* nm);\n+ object mcall(const char* nm, tuple& args);\n+ object mcall(const char* nm, tuple& args, dict& kwargs);\n+\n+ object mcall(std::string nm) {\n+ return mcall(nm.c_str());\n+ }\n+ object mcall(std::string nm, tuple& args) {\n+ return mcall(nm.c_str(),args);\n+ }\n+ object mcall(std::string nm, tuple& args, dict& kwargs) {\n+ return mcall(nm.c_str(),args,kwargs);\n+ }\n+\n+ object call() const;\n+ object call(tuple& args) const;\n+ object call(tuple& args, dict& kws) const;\n+\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n", "added_lines": 36, "deleted_lines": 8, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));\n };\n object attr(std::string nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));\n };\n object attr(const object& nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttr(_obj, nm)));\n }; \n \n int set_attr(const char* nm, object& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n };\n int set_attr(PyObject* nm, object& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n PyObject* attr(const char* nm) const {\n return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n };\n PyObject* attr(const object& nm) const {\n return LoseRef(PyObject_GetAttr(_obj, nm));\n };\n \n \n int set_attr(const char* nm, object& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n };\n int set_attr(PyObject* nm, object& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n \n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 55, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "nm" ], "start_line": 63, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 76, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 79, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 101, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 108, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 127, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 142, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 145, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 154, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 33, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 43, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 50, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 61, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 69, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 76, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 80, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 99, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "nm" ], "start_line": 63, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "nloc": 120, "complexity": 34, "token_count": 839, "diff_parsed": { "added": [ "#include ", "", "// used in method call specification.", "class tuple;", "class dict;", " object attr(const char* nm) const {", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));", " };", " object attr(std::string nm) const {", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));", " };", " object attr(const object& nm) const {", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttr(_obj, nm)));", " };", "", " object mcall(const char* nm);", " object mcall(const char* nm, tuple& args);", " object mcall(const char* nm, tuple& args, dict& kwargs);", "", " object mcall(std::string nm) {", " return mcall(nm.c_str());", " }", " object mcall(std::string nm, tuple& args) {", " return mcall(nm.c_str(),args);", " }", " object mcall(std::string nm, tuple& args, dict& kwargs) {", " return mcall(nm.c_str(),args,kwargs);", " }", "", " object call() const;", " object call(tuple& args) const;", " object call(tuple& args, dict& kws) const;", "" ], "deleted": [ " PyObject* attr(const char* nm) const {", " return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));", " };", " PyObject* attr(const object& nm) const {", " return LoseRef(PyObject_GetAttr(_obj, nm));", " };", "", "" ] } }, { "old_path": "weave/scxx/weave_imp.cpp", "new_path": "weave/scxx/weave_imp.cpp", "filename": "weave_imp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -25,6 +25,52 @@ void object::GrabRef(PyObject* newObj)\n _own = _obj = newObj;\n }\n \n+object object::mcall(const char* nm)\n+{\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(result);\n+}\n+\n+object object::mcall(const char* nm, tuple& args)\n+{\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(result);\n+}\n+\n+object object::mcall(const char* nm, tuple& args, dict& kwargs)\n+{\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(result);\n+}\n+\n+object object::call() const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(rslt);\n+}\n+object object::call(tuple& args) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(rslt);\n+}\n+object object::call(tuple& args, dict& kws) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(rslt);\n+}\n+\n //---------------------------------------------------------------------------\n // sequence\n //---------------------------------------------------------------------------\n", "added_lines": 46, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nobject object::mcall(const char* nm)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::mcall(const char* nm, tuple& args)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::mcall(const char* nm, tuple& args, dict& kwargs)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\nobject object::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\nobject object::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "methods": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 46, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 50, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 83, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 123, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 127, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 202, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 226, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 245, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 267, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 279, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 285, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 295, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 302, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 308, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 37, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 47, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 52, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 81, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 146, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 156, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 161, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 170, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 187, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 199, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 205, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 215, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 221, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 249, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 256, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 262, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 269, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 46, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 50, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 235, "complexity": 56, "token_count": 1612, "diff_parsed": { "added": [ "object object::mcall(const char* nm)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(result);", "}", "", "object object::mcall(const char* nm, tuple& args)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(result);", "}", "", "object object::mcall(const char* nm, tuple& args, dict& kwargs)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);", " if (!result)", " throw 1; // signal exception has occured.", " return object(result);", "}", "", "object object::call() const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);", " if (rslt == 0)", " throw 1;", " return object(rslt);", "}", "object object::call(tuple& args) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);", " if (rslt == 0)", " throw 1;", " return object(rslt);", "}", "object object::call(tuple& args, dict& kws) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);", " if (rslt == 0)", " throw 1;", " return object(rslt);", "}", "" ], "deleted": [] } } ] }, { "hash": "211c1371b80fdf4c082b25082d3f13572441217f", "msg": "cleaned up DOS line endings\n\nadded scxx test suite", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-28T08:55:55+00:00", "author_timezone": 0, "committer_date": "2002-09-28T08:55:55+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "79486d23803b7be8f2510f6d2f5a70425f314f2b" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 2, "insertions": 291, "lines": 293, "files": 2, "dmm_unit_size": 0.20588235294117646, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/setup_weave.py", "new_path": "weave/setup_weave.py", "filename": "setup_weave.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -12,8 +12,8 @@ def configuration(parent_package=''):\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n- scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))\n- install_path = os.path.join(parent_path,'weave','scxx2')\n+ scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n+ install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n local_path = get_path(__name__)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n local_path = get_path(__name__)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx2')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "nloc": 40, "complexity": 1, "token_count": 438, "diff_parsed": { "added": [ " scxx_files = glob(os.path.join(local_path,'scxx','*.*'))", " install_path = os.path.join(parent_path,'weave','scxx')" ], "deleted": [ " scxx_files = glob(os.path.join(local_path,'scxx2','*.*'))", " install_path = os.path.join(parent_path,'weave','scxx2')" ] } }, { "old_path": null, "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,289 @@\n+\"\"\" Test refcounting and behavior of SCXX.\n+\"\"\"\n+import unittest\n+import time\n+import os,sys\n+from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n+\n+add_grandparent_to_path(__name__)\n+import inline_tools\n+restore_path()\n+\n+# Test:\n+# append DONE\n+# insert DONE\n+# in DONE\n+# count DONE\n+# setItem DONE\n+# operator[] (get)\n+# operator[] (set) DONE\n+\n+class test_list(unittest.TestCase):\n+ def check_conversion(self):\n+ a = []\n+ before = sys.getrefcount(a)\n+ import weave\n+ weave.inline(\"\",['a'])\n+ \n+ # first call is goofing up refcount.\n+ before = sys.getrefcount(a) \n+ weave.inline(\"\",['a'])\n+ after = sys.getrefcount(a) \n+ assert(after == before)\n+\n+ def check_append_passed_item(self):\n+ a = []\n+ item = 1\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.append(item);\",['a','item'])\n+ del a[0] \n+ \n+ before1 = sys.getrefcount(a)\n+ before2 = sys.getrefcount(item)\n+ inline_tools.inline(\"a.append(item);\",['a','item'])\n+ assert a[0] is item\n+ del a[0] \n+ after1 = sys.getrefcount(a)\n+ after2 = sys.getrefcount(item)\n+ assert after1 == before1\n+ assert after2 == before2\n+\n+ \n+ def check_append(self):\n+ a = []\n+\n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.append(1);\",['a'])\n+ del a[0] \n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded append(int val) method\n+ inline_tools.inline(\"a.append(1234);\",['a']) \n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 1234\n+ del a[0] \n+\n+ # check overloaded append(double val) method\n+ inline_tools.inline(\"a.append(123.0);\",['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 123.0\n+ del a[0] \n+ \n+ # check overloaded append(char* val) method \n+ inline_tools.inline('a.append(\"bubba\");',['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 'bubba'\n+ del a[0] \n+ \n+ # check overloaded append(std::string val) method\n+ inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 'sissy'\n+ del a[0] \n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+\n+ def check_insert(self):\n+ a = [1,2,3]\n+ \n+ a.insert(1,234)\n+ del a[1]\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.insert(1,1234);\",['a'])\n+ del a[1] \n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded insert(int ndx, int val) method\n+ inline_tools.inline(\"a.insert(1,1234);\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+ del a[1] \n+\n+ # check overloaded insert(int ndx, double val) method\n+ inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0\n+ del a[1] \n+ \n+ # check overloaded insert(int ndx, char* val) method \n+ inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ del a[1] \n+ \n+ # check overloaded insert(int ndx, std::string val) method\n+ inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ del a[0] \n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+\n+ def check_set_item(self):\n+ a = [1,2,3]\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.setItem(1,1234);\",['a'])\n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded insert(int ndx, int val) method\n+ inline_tools.inline(\"a.setItem(1,1234);\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+\n+ # check overloaded insert(int ndx, double val) method\n+ inline_tools.inline(\"a.setItem(1,123.0);\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0\n+ \n+ # check overloaded insert(int ndx, char* val) method \n+ inline_tools.inline('a.setItem(1,\"bubba\");',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ \n+ # check overloaded insert(int ndx, std::string val) method\n+ inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+\n+ def check_set_item_operator_equal(self):\n+ a = [1,2,3]\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a[1] = 1234;\",['a'])\n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded insert(int ndx, int val) method\n+ inline_tools.inline(\"a[1] = 1234;\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+\n+ # check overloaded insert(int ndx, double val) method\n+ inline_tools.inline(\"a[1] = 123.0;\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0\n+ \n+ # check overloaded insert(int ndx, char* val) method \n+ inline_tools.inline('a[1] = \"bubba\";',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ \n+ # check overloaded insert(int ndx, std::string val) method\n+ inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+\n+ def check_in(self):\n+ \"\"\" Test the \"in\" method for lists. We'll assume\n+ it works for sequences if it works here.\n+ \"\"\"\n+ a = [1,2,'alpha',3.1416]\n+\n+ # check overloaded in(PWOBase& val) method\n+ item = 1\n+ code = \"return_val = PyInt_FromLong(a.in(item));\"\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 1\n+ item = 0\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 0\n+ \n+ # check overloaded in(int val) method\n+ code = \"return_val = PyInt_FromLong(a.in(1));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = \"return_val = PyInt_FromLong(a.in(0));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(double val) method\n+ code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(char* val) method \n+ code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(std::string val) method\n+ code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+\n+ def check_count(self):\n+ \"\"\" Test the \"count\" method for lists. We'll assume\n+ it works for sequences if it works hre.\n+ \"\"\"\n+ a = [1,2,'alpha',3.1416]\n+\n+ # check overloaded count(PWOBase& val) method\n+ item = 1\n+ code = \"return_val = PyInt_FromLong(a.count(item));\"\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 1\n+ \n+ # check overloaded count(int val) method\n+ code = \"return_val = PyInt_FromLong(a.count(1));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(double val) method\n+ code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(char* val) method \n+ code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(std::string val) method\n+ code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+\n+class test_call:\n+ \"\"\" Need to test calling routines.\n+ \"\"\"\n+ pass\n+ \n+def test_suite(level=1):\n+ from unittest import makeSuite\n+ suites = [] \n+ if level >= 5:\n+ suites.append( makeSuite(test_list,'check_'))\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+def test(level=10):\n+ all_tests = test_suite(level)\n+ runner = unittest.TextTestRunner()\n+ runner.run(all_tests)\n+ return runner\n+\n+if __name__ == \"__main__\":\n+ test()\n", "added_lines": 289, "deleted_lines": 0, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.setItem(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.setItem(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.setItem(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.setItem(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\nclass test_call:\n \"\"\" Need to test calling routines.\n \"\"\"\n pass\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": null, "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 282, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 282, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 186, "complexity": 11, "token_count": 1321, "diff_parsed": { "added": [ "\"\"\" Test refcounting and behavior of SCXX.", "\"\"\"", "import unittest", "import time", "import os,sys", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", "restore_path()", "", "# Test:", "# append DONE", "# insert DONE", "# in DONE", "# count DONE", "# setItem DONE", "# operator[] (get)", "# operator[] (set) DONE", "", "class test_list(unittest.TestCase):", " def check_conversion(self):", " a = []", " before = sys.getrefcount(a)", " import weave", " weave.inline(\"\",['a'])", "", " # first call is goofing up refcount.", " before = sys.getrefcount(a)", " weave.inline(\"\",['a'])", " after = sys.getrefcount(a)", " assert(after == before)", "", " def check_append_passed_item(self):", " a = []", " item = 1", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(item);\",['a','item'])", " del a[0]", "", " before1 = sys.getrefcount(a)", " before2 = sys.getrefcount(item)", " inline_tools.inline(\"a.append(item);\",['a','item'])", " assert a[0] is item", " del a[0]", " after1 = sys.getrefcount(a)", " after2 = sys.getrefcount(item)", " assert after1 == before1", " assert after2 == before2", "", "", " def check_append(self):", " a = []", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(1);\",['a'])", " del a[0]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded append(int val) method", " inline_tools.inline(\"a.append(1234);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 1234", " del a[0]", "", " # check overloaded append(double val) method", " inline_tools.inline(\"a.append(123.0);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 123.0", " del a[0]", "", " # check overloaded append(char* val) method", " inline_tools.inline('a.append(\"bubba\");',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'bubba'", " del a[0]", "", " # check overloaded append(std::string val) method", " inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_insert(self):", " a = [1,2,3]", "", " a.insert(1,234)", " del a[1]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " del a[1]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", " del a[1]", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a.insert(1,123.0);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", " del a[1]", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a.insert(1,\"bubba\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", " del a[1]", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_set_item(self):", " a = [1,2,3]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.setItem(1,1234);\",['a'])", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a.setItem(1,1234);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a.setItem(1,123.0);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a.setItem(1,\"bubba\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_set_item_operator_equal(self):", " a = [1,2,3]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a[1] = 1234;\",['a'])", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a[1] = 123.0;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a[1] = \"bubba\";',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_in(self):", " \"\"\" Test the \"in\" method for lists. We'll assume", " it works for sequences if it works here.", " \"\"\"", " a = [1,2,'alpha',3.1416]", "", " # check overloaded in(PWOBase& val) method", " item = 1", " code = \"return_val = PyInt_FromLong(a.in(item));\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", " item = 0", " res = inline_tools.inline(code,['a','item'])", " assert res == 0", "", " # check overloaded in(int val) method", " code = \"return_val = PyInt_FromLong(a.in(1));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = PyInt_FromLong(a.in(0));\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(double val) method", " code = \"return_val = PyInt_FromLong(a.in(3.1416));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = PyInt_FromLong(a.in(3.1417));\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(char* val) method", " code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(std::string val) method", " code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " def check_count(self):", " \"\"\" Test the \"count\" method for lists. We'll assume", " it works for sequences if it works hre.", " \"\"\"", " a = [1,2,'alpha',3.1416]", "", " # check overloaded count(PWOBase& val) method", " item = 1", " code = \"return_val = PyInt_FromLong(a.count(item));\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", "", " # check overloaded count(int val) method", " code = \"return_val = PyInt_FromLong(a.count(1));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(double val) method", " code = \"return_val = PyInt_FromLong(a.count(3.1416));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(char* val) method", " code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(std::string val) method", " code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", "class test_call:", " \"\"\" Need to test calling routines.", " \"\"\"", " pass", "", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " suites.append( makeSuite(test_list,'check_'))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ], "deleted": [] } } ] }, { "hash": "0b2c911fc467141ca59b1b021d42fc3441598833", "msg": "Moved orginal SCXX files to newly named files that reflect the type they\ncontained. The objects have also been given more boost like names.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-28T08:59:30+00:00", "author_timezone": 0, "committer_date": "2002-09-28T08:59:30+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "211c1371b80fdf4c082b25082d3f13572441217f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1167, "insertions": 0, "lines": 1167, "files": 7, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.014906832298136646, "modified_files": [ { "old_path": "weave/scxx/PWOBase.h", "new_path": null, "filename": "PWOBase.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,124 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-// PWOBase.h: interface for the PWOBase class.\n-\n-#if !defined(PWOBASE_H_INCLUDED_)\n-#define PWOBASE_H_INCLUDED_\n-\n-#include \n-#include \n-\n-void Fail(PyObject*, const char* msg);\n-\n-class PWOBase \n-{\n-protected:\n- PyObject* _obj;\n-\n- // incref new owner, decref old owner, and adjust to new owner\n- void GrabRef(PyObject* newObj);\n- // decrease reference count without destroying the object\n- static PyObject* LoseRef(PyObject* o)\n- { if (o != 0) --(o->ob_refcnt); return o; }\n-\n-private:\n- PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n-\n-public:\n- PWOBase()\n- : _obj (0), _own (0) { }\n- PWOBase(const PWOBase& other)\n- : _obj (0), _own (0) { GrabRef(other); }\n- PWOBase(PyObject* obj)\n- : _obj (0), _own (0) { GrabRef(obj); }\n-\n- virtual ~PWOBase()\n- { Py_XDECREF(_own); }\n- \n- PWOBase& operator=(const PWOBase& other) {\n- GrabRef(other);\n- return *this;\n- };\n- operator PyObject* () const {\n- return _obj;\n- };\n- int print(FILE *f, int flags) const {\n- return PyObject_Print(_obj, f, flags);\n- };\n- bool hasAttr(const char* nm) const {\n- return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n- };\n- //bool hasAttr(PyObject* nm) const {\n- // return PyObject_HasAttr(_obj, nm);\n- //};\n- PyObject* getAttr(const char* nm) const {\n- return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n- };\n- PyObject* getAttr(const PWOBase& nm) const {\n- return LoseRef(PyObject_GetAttr(_obj, nm));\n- };\n- int setAttr(const char* nm, PWOBase& val) {\n- return PyObject_SetAttrString(_obj, (char*) nm, val);\n- };\n- int setAttr(PyObject* nm, PWOBase& val) {\n- return PyObject_SetAttr(_obj, nm, val);\n- };\n- int delAttr(const char* nm) {\n- return PyObject_DelAttrString(_obj, (char*) nm);\n- };\n- int delAttr(const PWOBase& nm) {\n- return PyObject_DelAttr(_obj, nm);\n- };\n- int cmp(const PWOBase& other) const {\n- int rslt = 0;\n- int rc = PyObject_Cmp(_obj, other, &rslt);\n- if (rc == -1)\n- Fail(PyExc_TypeError, \"cannot make the comparison\");\n- return rslt;\n- };\n- bool operator == (const PWOBase& other) const {\n- return cmp(other) == 0;\n- };\n- bool operator != (const PWOBase& other) const {\n- return cmp(other) != 0;\n- };\n- bool operator > (const PWOBase& other) const {\n- return cmp(other) > 0;\n- };\n- bool operator < (const PWOBase& other) const {\n- return cmp(other) < 0;\n- };\n- bool operator >= (const PWOBase& other) const {\n- return cmp(other) >= 0;\n- };\n- bool operator <= (const PWOBase& other) const {\n- return cmp(other) <= 0;\n- };\n- \n- PyObject* repr() const {\n- return LoseRef(PyObject_Repr(_obj));\n- };\n- PyObject* str() const {\n- return LoseRef(PyObject_Str(_obj));\n- };\n- bool isCallable() const {\n- return PyCallable_Check(_obj) == 1;\n- };\n- int hash() const {\n- return PyObject_Hash(_obj);\n- };\n- bool isTrue() const {\n- return PyObject_IsTrue(_obj) == 1;\n- };\n- PyObject* type() const {\n- return LoseRef(PyObject_Type(_obj));\n- };\n- PyObject* disOwn() {\n- _own = 0;\n- return _obj;\n- };\n-};\n-\n-#endif // !defined(PWOBASE_H_INCLUDED_)\n", "added_lines": 0, "deleted_lines": 124, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n// PWOBase.h: interface for the PWOBase class.\n\n#if !defined(PWOBASE_H_INCLUDED_)\n#define PWOBASE_H_INCLUDED_\n\n#include \n#include \n\nvoid Fail(PyObject*, const char* msg);\n\nclass PWOBase \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n PWOBase()\n : _obj (0), _own (0) { }\n PWOBase(const PWOBase& other)\n : _obj (0), _own (0) { GrabRef(other); }\n PWOBase(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~PWOBase()\n { Py_XDECREF(_own); }\n \n PWOBase& operator=(const PWOBase& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasAttr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n //bool hasAttr(PyObject* nm) const {\n // return PyObject_HasAttr(_obj, nm);\n //};\n PyObject* getAttr(const char* nm) const {\n return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));\n };\n PyObject* getAttr(const PWOBase& nm) const {\n return LoseRef(PyObject_GetAttr(_obj, nm));\n };\n int setAttr(const char* nm, PWOBase& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n };\n int setAttr(PyObject* nm, PWOBase& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n int delAttr(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int delAttr(const PWOBase& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n int cmp(const PWOBase& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const PWOBase& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const PWOBase& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const PWOBase& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const PWOBase& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const PWOBase& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const PWOBase& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n bool isCallable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool isTrue() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disOwn() {\n _own = 0;\n return _obj;\n };\n};\n\n#endif // !defined(PWOBASE_H_INCLUDED_)\n", "methods": [], "methods_before": [ { "name": "PWOBase::LoseRef", "long_name": "PWOBase::LoseRef( PyObject * o)", "filename": "PWOBase.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 23, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase()", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 30, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase( const PWOBase & other)", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 32, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase( PyObject * obj)", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 34, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::~PWOBase", "long_name": "PWOBase::~PWOBase()", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::operator =", "long_name": "PWOBase::operator =( const PWOBase & other)", "filename": "PWOBase.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOBase::operator PyObject *", "long_name": "PWOBase::operator PyObject *() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 44, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::print", "long_name": "PWOBase::print( FILE * f , int flags) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::hasAttr", "long_name": "PWOBase::hasAttr( const char * nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 50, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::getAttr", "long_name": "PWOBase::getAttr( const char * nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "nm" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::getAttr", "long_name": "PWOBase::getAttr( const PWOBase & nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 59, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::setAttr", "long_name": "PWOBase::setAttr( const char * nm , PWOBase & val)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 62, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::setAttr", "long_name": "PWOBase::setAttr( PyObject * nm , PWOBase & val)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 65, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::delAttr", "long_name": "PWOBase::delAttr( const char * nm)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::delAttr", "long_name": "PWOBase::delAttr( const PWOBase & nm)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 71, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::cmp", "long_name": "PWOBase::cmp( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 74, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOBase::operator ==", "long_name": "PWOBase::operator ==( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator !=", "long_name": "PWOBase::operator !=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 84, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator >", "long_name": "PWOBase::operator >( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator <", "long_name": "PWOBase::operator <( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator >=", "long_name": "PWOBase::operator >=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator <=", "long_name": "PWOBase::operator <=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::repr", "long_name": "PWOBase::repr() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::str", "long_name": "PWOBase::str() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::isCallable", "long_name": "PWOBase::isCallable() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::hash", "long_name": "PWOBase::hash() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 109, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::isTrue", "long_name": "PWOBase::isTrue() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::type", "long_name": "PWOBase::type() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::disOwn", "long_name": "PWOBase::disOwn()", "filename": "PWOBase.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOBase::delAttr", "long_name": "PWOBase::delAttr( const char * nm)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::isCallable", "long_name": "PWOBase::isCallable() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator PyObject *", "long_name": "PWOBase::operator PyObject *() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 44, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase( const PWOBase & other)", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 32, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::setAttr", "long_name": "PWOBase::setAttr( const char * nm , PWOBase & val)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 62, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator >", "long_name": "PWOBase::operator >( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::setAttr", "long_name": "PWOBase::setAttr( PyObject * nm , PWOBase & val)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 65, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator ==", "long_name": "PWOBase::operator ==( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::disOwn", "long_name": "PWOBase::disOwn()", "filename": "PWOBase.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOBase::cmp", "long_name": "PWOBase::cmp( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 74, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOBase::getAttr", "long_name": "PWOBase::getAttr( const PWOBase & nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 59, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::hasAttr", "long_name": "PWOBase::hasAttr( const char * nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 50, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::repr", "long_name": "PWOBase::repr() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator <", "long_name": "PWOBase::operator <( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase()", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 30, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::LoseRef", "long_name": "PWOBase::LoseRef( PyObject * o)", "filename": "PWOBase.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 23, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::hash", "long_name": "PWOBase::hash() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 109, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::~PWOBase", "long_name": "PWOBase::~PWOBase()", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::operator !=", "long_name": "PWOBase::operator !=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 84, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator <=", "long_name": "PWOBase::operator <=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 96, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::str", "long_name": "PWOBase::str() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::PWOBase", "long_name": "PWOBase::PWOBase( PyObject * obj)", "filename": "PWOBase.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 34, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOBase::delAttr", "long_name": "PWOBase::delAttr( const PWOBase & nm)", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 71, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::print", "long_name": "PWOBase::print( FILE * f , int flags) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator =", "long_name": "PWOBase::operator =( const PWOBase & other)", "filename": "PWOBase.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOBase::isTrue", "long_name": "PWOBase::isTrue() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::type", "long_name": "PWOBase::type() const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::getAttr", "long_name": "PWOBase::getAttr( const char * nm) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "nm" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOBase::operator >=", "long_name": "PWOBase::operator >=( const PWOBase & other) const", "filename": "PWOBase.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "// PWOBase.h: interface for the PWOBase class.", "", "#if !defined(PWOBASE_H_INCLUDED_)", "#define PWOBASE_H_INCLUDED_", "", "#include ", "#include ", "", "void Fail(PyObject*, const char* msg);", "", "class PWOBase", "{", "protected:", " PyObject* _obj;", "", " // incref new owner, decref old owner, and adjust to new owner", " void GrabRef(PyObject* newObj);", " // decrease reference count without destroying the object", " static PyObject* LoseRef(PyObject* o)", " { if (o != 0) --(o->ob_refcnt); return o; }", "", "private:", " PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero", "", "public:", " PWOBase()", " : _obj (0), _own (0) { }", " PWOBase(const PWOBase& other)", " : _obj (0), _own (0) { GrabRef(other); }", " PWOBase(PyObject* obj)", " : _obj (0), _own (0) { GrabRef(obj); }", "", " virtual ~PWOBase()", " { Py_XDECREF(_own); }", "", " PWOBase& operator=(const PWOBase& other) {", " GrabRef(other);", " return *this;", " };", " operator PyObject* () const {", " return _obj;", " };", " int print(FILE *f, int flags) const {", " return PyObject_Print(_obj, f, flags);", " };", " bool hasAttr(const char* nm) const {", " return PyObject_HasAttrString(_obj, (char*) nm) == 1;", " };", " //bool hasAttr(PyObject* nm) const {", " // return PyObject_HasAttr(_obj, nm);", " //};", " PyObject* getAttr(const char* nm) const {", " return LoseRef(PyObject_GetAttrString(_obj, (char*) nm));", " };", " PyObject* getAttr(const PWOBase& nm) const {", " return LoseRef(PyObject_GetAttr(_obj, nm));", " };", " int setAttr(const char* nm, PWOBase& val) {", " return PyObject_SetAttrString(_obj, (char*) nm, val);", " };", " int setAttr(PyObject* nm, PWOBase& val) {", " return PyObject_SetAttr(_obj, nm, val);", " };", " int delAttr(const char* nm) {", " return PyObject_DelAttrString(_obj, (char*) nm);", " };", " int delAttr(const PWOBase& nm) {", " return PyObject_DelAttr(_obj, nm);", " };", " int cmp(const PWOBase& other) const {", " int rslt = 0;", " int rc = PyObject_Cmp(_obj, other, &rslt);", " if (rc == -1)", " Fail(PyExc_TypeError, \"cannot make the comparison\");", " return rslt;", " };", " bool operator == (const PWOBase& other) const {", " return cmp(other) == 0;", " };", " bool operator != (const PWOBase& other) const {", " return cmp(other) != 0;", " };", " bool operator > (const PWOBase& other) const {", " return cmp(other) > 0;", " };", " bool operator < (const PWOBase& other) const {", " return cmp(other) < 0;", " };", " bool operator >= (const PWOBase& other) const {", " return cmp(other) >= 0;", " };", " bool operator <= (const PWOBase& other) const {", " return cmp(other) <= 0;", " };", "", " PyObject* repr() const {", " return LoseRef(PyObject_Repr(_obj));", " };", " PyObject* str() const {", " return LoseRef(PyObject_Str(_obj));", " };", " bool isCallable() const {", " return PyCallable_Check(_obj) == 1;", " };", " int hash() const {", " return PyObject_Hash(_obj);", " };", " bool isTrue() const {", " return PyObject_IsTrue(_obj) == 1;", " };", " PyObject* type() const {", " return LoseRef(PyObject_Type(_obj));", " };", " PyObject* disOwn() {", " _own = 0;", " return _obj;", " };", "};", "", "#endif // !defined(PWOBASE_H_INCLUDED_)" ] } }, { "old_path": "weave/scxx/PWOCallable.h", "new_path": null, "filename": "PWOCallable.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,40 +0,0 @@\n-/******************************************** \n- copyright 2000 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#if !defined(PWOCALLABLE_H_INCLUDED_)\n-#define PWOCALLABLE_H_INCLUDED_\n-\n-#include \"PWOBase.h\"\n-#include \"PWOSequence.h\"\n-#include \"PWOMapping.h\"\n-\n-class PWOCallable : public PWOBase\n-{\n-public:\n- PWOCallable() : PWOBase() {};\n- PWOCallable(PyObject *obj) : PWOBase(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~PWOCallable() {};\n- virtual PWOCallable& operator=(const PWOCallable& other) {\n- GrabRef(other);\n- return *this;\n- };\n- PWOCallable& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!isCallable()) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a callable object\");\n- }\n- };\n- PWOBase call() const;\n- PWOBase call(PWOTuple& args) const;\n- PWOBase call(PWOTuple& args, PWOMapping& kws) const;\n-};\n-\n-#endif\n", "added_lines": 0, "deleted_lines": 40, "source_code": null, "source_code_before": "/******************************************** \n copyright 2000 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOCALLABLE_H_INCLUDED_)\n#define PWOCALLABLE_H_INCLUDED_\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \"PWOMapping.h\"\n\nclass PWOCallable : public PWOBase\n{\npublic:\n PWOCallable() : PWOBase() {};\n PWOCallable(PyObject *obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOCallable() {};\n virtual PWOCallable& operator=(const PWOCallable& other) {\n GrabRef(other);\n return *this;\n };\n PWOCallable& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!isCallable()) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a callable object\");\n }\n };\n PWOBase call() const;\n PWOBase call(PWOTuple& args) const;\n PWOBase call(PWOTuple& args, PWOMapping& kws) const;\n};\n\n#endif\n", "methods": [], "methods_before": [ { "name": "PWOCallable::PWOCallable", "long_name": "PWOCallable::PWOCallable()", "filename": "PWOCallable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 15, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOCallable::PWOCallable", "long_name": "PWOCallable::PWOCallable( PyObject * obj)", "filename": "PWOCallable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 16, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOCallable::~PWOCallable", "long_name": "PWOCallable::~PWOCallable()", "filename": "PWOCallable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOCallable::operator =", "long_name": "PWOCallable::operator =( const PWOCallable & other)", "filename": "PWOCallable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOCallable::operator =", "long_name": "PWOCallable::operator =( const PWOBase & other)", "filename": "PWOCallable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOCallable::_violentTypeCheck", "long_name": "PWOCallable::_violentTypeCheck()", "filename": "PWOCallable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOCallable::operator =", "long_name": "PWOCallable::operator =( const PWOBase & other)", "filename": "PWOCallable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOCallable::operator =", "long_name": "PWOCallable::operator =( const PWOCallable & other)", "filename": "PWOCallable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOCallable::_violentTypeCheck", "long_name": "PWOCallable::_violentTypeCheck()", "filename": "PWOCallable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOCallable::~PWOCallable", "long_name": "PWOCallable::~PWOCallable()", "filename": "PWOCallable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOCallable::PWOCallable", "long_name": "PWOCallable::PWOCallable()", "filename": "PWOCallable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 15, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOCallable::PWOCallable", "long_name": "PWOCallable::PWOCallable( PyObject * obj)", "filename": "PWOCallable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 16, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 2000 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#if !defined(PWOCALLABLE_H_INCLUDED_)", "#define PWOCALLABLE_H_INCLUDED_", "", "#include \"PWOBase.h\"", "#include \"PWOSequence.h\"", "#include \"PWOMapping.h\"", "", "class PWOCallable : public PWOBase", "{", "public:", " PWOCallable() : PWOBase() {};", " PWOCallable(PyObject *obj) : PWOBase(obj) {", " _violentTypeCheck();", " };", " virtual ~PWOCallable() {};", " virtual PWOCallable& operator=(const PWOCallable& other) {", " GrabRef(other);", " return *this;", " };", " PWOCallable& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!isCallable()) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a callable object\");", " }", " };", " PWOBase call() const;", " PWOBase call(PWOTuple& args) const;", " PWOBase call(PWOTuple& args, PWOMapping& kws) const;", "};", "", "#endif" ] } }, { "old_path": "weave/scxx/PWOImp.cpp", "new_path": null, "filename": "PWOImp.cpp", "extension": "cpp", "change_type": "DELETE", "diff": "@@ -1,197 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#include \"PWOSequence.h\"\n-#include \"PWOMSequence.h\"\n-#include \"PWOMapping.h\"\n-#include \"PWOCallable.h\"\n-#include \"PWONumber.h\"\n-\n- // incref new owner, and decref old owner, and adjust to new owner\n-void PWOBase::GrabRef(PyObject* newObj)\n-{\n- // be careful to incref before decref if old is same as new\n- Py_XINCREF(newObj);\n- Py_XDECREF(_own);\n- _own = _obj = newObj;\n-}\n-\n-bool PWOSequence::in(int value) {\n- PWOBase val = PWONumber(value);\n- return in(val);\n-};\n- \n-bool PWOSequence::in(double value) {\n- PWOBase val = PWONumber(value);\n- return in(val);\n-};\n-\n-bool PWOSequence::in(char* value) {\n- PWOBase val = PWOString(value);\n- return in(val);\n-};\n-\n-bool PWOSequence::in(std::string value) {\n- PWOBase val = PWOString(value.c_str());\n- return in(val);\n-};\n- \n-int PWOSequence::count(int value) const {\n- PWONumber val = PWONumber(value);\n- return count(val);\n-};\n-\n-int PWOSequence::count(double value) const {\n- PWONumber val = PWONumber(value);\n- return count(val);\n-};\n-\n-int PWOSequence::count(char* value) const {\n- PWOString val = PWOString(value);\n- return count(val);\n-};\n-\n-int PWOSequence::count(std::string value) const {\n- PWOString val = PWOString(value.c_str());\n- return count(val);\n-};\n-\n-int PWOSequence::index(int value) const {\n- PWONumber val = PWONumber(value);\n- return index(val);\n-};\n-\n-int PWOSequence::index(double value) const {\n- PWONumber val = PWONumber(value);\n- return index(val);\n-};\n-int PWOSequence::index(char* value) const {\n- PWOString val = PWOString(value);\n- return index(val);\n-};\n-\n-int PWOSequence::index(std::string value) const {\n- PWOString val = PWOString(value.c_str());\n- return index(val);\n-};\n-\n-PWOTuple::PWOTuple(const PWOList& list)\n- : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n- \n-PWOList& PWOList::insert(int ndx, int other) {\n- PWONumber oth = PWONumber(other);\n- return insert(ndx, oth);\n-};\n-\n-PWOList& PWOList::insert(int ndx, double other) {\n- PWONumber oth = PWONumber(other);\n- return insert(ndx, oth);\n-};\n-\n-PWOList& PWOList::insert(int ndx, char* other) {\n- PWOString oth = PWOString(other);\n- return insert(ndx, oth);\n-};\n-\n-PWOList& PWOList::insert(int ndx, std::string other) {\n- PWOString oth = PWOString(other.c_str());\n- return insert(ndx, oth);\n-};\n-\n-PWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n- : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n-\n-PWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for setItem to steal\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for setItem to steal\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOListMmbr& PWOListMmbr::operator=(int other) {\n- GrabRef(PWONumber(other));\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOListMmbr& PWOListMmbr::operator=(double other) {\n- GrabRef(PWONumber(other));\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOListMmbr& PWOListMmbr::operator=(const char* other) {\n- GrabRef(PWOString(other));\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOListMmbr& PWOListMmbr::operator=(std::string other) {\n- GrabRef(PWOString(other.c_str()));\n- _parent.setItem(_ndx, *this);\n- return *this;\n-}\n-\n-PWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n- GrabRef(other);\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n-PWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n- GrabRef(PWONumber(other));\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n-PWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n- GrabRef(PWONumber(other));\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n-PWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n- GrabRef(PWOString(other));\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n-PWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n- GrabRef(PWOString(other.c_str()));\n- _parent.setItem(_key, *this);\n- return *this;\n-}\n-\n-PWOBase PWOCallable::call() const {\n- static PWOTuple _empty;\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-PWOBase PWOCallable::call(PWOTuple& args) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-PWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-\n-void Fail(PyObject* exc, const char* msg)\n-{\n- PyErr_SetString(exc, msg);\n- throw 1;\n-}\n", "added_lines": 0, "deleted_lines": 197, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"PWOSequence.h\"\n#include \"PWOMSequence.h\"\n#include \"PWOMapping.h\"\n#include \"PWOCallable.h\"\n#include \"PWONumber.h\"\n\n // incref new owner, and decref old owner, and adjust to new owner\nvoid PWOBase::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nbool PWOSequence::in(int value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n \nbool PWOSequence::in(double value) {\n PWOBase val = PWONumber(value);\n return in(val);\n};\n\nbool PWOSequence::in(char* value) {\n PWOBase val = PWOString(value);\n return in(val);\n};\n\nbool PWOSequence::in(std::string value) {\n PWOBase val = PWOString(value.c_str());\n return in(val);\n};\n \nint PWOSequence::count(int value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(double value) const {\n PWONumber val = PWONumber(value);\n return count(val);\n};\n\nint PWOSequence::count(char* value) const {\n PWOString val = PWOString(value);\n return count(val);\n};\n\nint PWOSequence::count(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return count(val);\n};\n\nint PWOSequence::index(int value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\n\nint PWOSequence::index(double value) const {\n PWONumber val = PWONumber(value);\n return index(val);\n};\nint PWOSequence::index(char* value) const {\n PWOString val = PWOString(value);\n return index(val);\n};\n\nint PWOSequence::index(std::string value) const {\n PWOString val = PWOString(value.c_str());\n return index(val);\n};\n\nPWOTuple::PWOTuple(const PWOList& list)\n : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }\n \nPWOList& PWOList::insert(int ndx, int other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, double other) {\n PWONumber oth = PWONumber(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, char* other) {\n PWOString oth = PWOString(other);\n return insert(ndx, oth);\n};\n\nPWOList& PWOList::insert(int ndx, std::string other) {\n PWOString oth = PWOString(other.c_str());\n return insert(ndx, oth);\n};\n\nPWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx) \n : PWOBase(obj), _parent(parent), _ndx(ndx) { }\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for setItem to steal\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOListMmbr& PWOListMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_ndx, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {\n GrabRef(other);\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(int other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(double other) {\n GrabRef(PWONumber(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {\n GrabRef(PWOString(other));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {\n GrabRef(PWOString(other.c_str()));\n _parent.setItem(_key, *this);\n return *this;\n}\n\nPWOBase PWOCallable::call() const {\n static PWOTuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nPWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "methods": [], "methods_before": [ { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOListMmbr & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 143, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 155, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 161, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 186, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "PWOSequence::in", "long_name": "PWOSequence::in( char * value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , double other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 87, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOList & list)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "list" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOListMmbr & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call( PWOTuple & args , PWOMapping & kws) const", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 186, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( double value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "Fail", "long_name": "Fail( PyObject * exc , const char * msg)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "exc", "msg" ], "start_line": 193, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const char * other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 161, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , std :: string other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( char * value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( int value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 60, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( int value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( double other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 155, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( int other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOBase::GrabRef", "long_name": "PWOBase::GrabRef( PyObject * newObj)", "filename": "PWOImp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOListMmbr::operator =", "long_name": "PWOListMmbr::operator =( std :: string other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 137, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( std :: string value)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOListMmbr::PWOListMmbr", "long_name": "PWOListMmbr::PWOListMmbr( PyObject * obj , PWOList & parent , int ndx)", "filename": "PWOImp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( double value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOMappingMmbr::operator =", "long_name": "PWOMappingMmbr::operator =( const PWOBase & other)", "filename": "PWOImp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 143, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "PWOCallable::call", "long_name": "PWOCallable::call() const", "filename": "PWOImp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , int other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 82, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , char * other)", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( std :: string value) const", "filename": "PWOImp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#include \"PWOSequence.h\"", "#include \"PWOMSequence.h\"", "#include \"PWOMapping.h\"", "#include \"PWOCallable.h\"", "#include \"PWONumber.h\"", "", " // incref new owner, and decref old owner, and adjust to new owner", "void PWOBase::GrabRef(PyObject* newObj)", "{", " // be careful to incref before decref if old is same as new", " Py_XINCREF(newObj);", " Py_XDECREF(_own);", " _own = _obj = newObj;", "}", "", "bool PWOSequence::in(int value) {", " PWOBase val = PWONumber(value);", " return in(val);", "};", "", "bool PWOSequence::in(double value) {", " PWOBase val = PWONumber(value);", " return in(val);", "};", "", "bool PWOSequence::in(char* value) {", " PWOBase val = PWOString(value);", " return in(val);", "};", "", "bool PWOSequence::in(std::string value) {", " PWOBase val = PWOString(value.c_str());", " return in(val);", "};", "", "int PWOSequence::count(int value) const {", " PWONumber val = PWONumber(value);", " return count(val);", "};", "", "int PWOSequence::count(double value) const {", " PWONumber val = PWONumber(value);", " return count(val);", "};", "", "int PWOSequence::count(char* value) const {", " PWOString val = PWOString(value);", " return count(val);", "};", "", "int PWOSequence::count(std::string value) const {", " PWOString val = PWOString(value.c_str());", " return count(val);", "};", "", "int PWOSequence::index(int value) const {", " PWONumber val = PWONumber(value);", " return index(val);", "};", "", "int PWOSequence::index(double value) const {", " PWONumber val = PWONumber(value);", " return index(val);", "};", "int PWOSequence::index(char* value) const {", " PWOString val = PWOString(value);", " return index(val);", "};", "", "int PWOSequence::index(std::string value) const {", " PWOString val = PWOString(value.c_str());", " return index(val);", "};", "", "PWOTuple::PWOTuple(const PWOList& list)", " : PWOSequence (PyList_AsTuple(list)) { LoseRef(_obj); }", "", "PWOList& PWOList::insert(int ndx, int other) {", " PWONumber oth = PWONumber(other);", " return insert(ndx, oth);", "};", "", "PWOList& PWOList::insert(int ndx, double other) {", " PWONumber oth = PWONumber(other);", " return insert(ndx, oth);", "};", "", "PWOList& PWOList::insert(int ndx, char* other) {", " PWOString oth = PWOString(other);", " return insert(ndx, oth);", "};", "", "PWOList& PWOList::insert(int ndx, std::string other) {", " PWOString oth = PWOString(other.c_str());", " return insert(ndx, oth);", "};", "", "PWOListMmbr::PWOListMmbr(PyObject* obj, PWOList& parent, int ndx)", " : PWOBase(obj), _parent(parent), _ndx(ndx) { }", "", "PWOListMmbr& PWOListMmbr::operator=(const PWOBase& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for setItem to steal", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOListMmbr& PWOListMmbr::operator=(const PWOListMmbr& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for setItem to steal", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOListMmbr& PWOListMmbr::operator=(int other) {", " GrabRef(PWONumber(other));", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOListMmbr& PWOListMmbr::operator=(double other) {", " GrabRef(PWONumber(other));", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOListMmbr& PWOListMmbr::operator=(const char* other) {", " GrabRef(PWOString(other));", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOListMmbr& PWOListMmbr::operator=(std::string other) {", " GrabRef(PWOString(other.c_str()));", " _parent.setItem(_ndx, *this);", " return *this;", "}", "", "PWOMappingMmbr& PWOMappingMmbr::operator=(const PWOBase& other) {", " GrabRef(other);", " _parent.setItem(_key, *this);", " return *this;", "}", "", "PWOMappingMmbr& PWOMappingMmbr::operator=(int other) {", " GrabRef(PWONumber(other));", " _parent.setItem(_key, *this);", " return *this;", "}", "", "PWOMappingMmbr& PWOMappingMmbr::operator=(double other) {", " GrabRef(PWONumber(other));", " _parent.setItem(_key, *this);", " return *this;", "}", "", "PWOMappingMmbr& PWOMappingMmbr::operator=(const char* other) {", " GrabRef(PWOString(other));", " _parent.setItem(_key, *this);", " return *this;", "}", "", "PWOMappingMmbr& PWOMappingMmbr::operator=(std::string other) {", " GrabRef(PWOString(other.c_str()));", " _parent.setItem(_key, *this);", " return *this;", "}", "", "PWOBase PWOCallable::call() const {", " static PWOTuple _empty;", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "PWOBase PWOCallable::call(PWOTuple& args) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "PWOBase PWOCallable::call(PWOTuple& args, PWOMapping& kws) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "", "void Fail(PyObject* exc, const char* msg)", "{", " PyErr_SetString(exc, msg);", " throw 1;", "}" ] } }, { "old_path": "weave/scxx/PWOMSequence.h", "new_path": null, "filename": "PWOMSequence.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,224 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n-#define PWOMSEQUENCE_H_INCLUDED_\n-\n-#if _MSC_VER >= 1000\n-#pragma once\n-#endif // _MSC_VER >= 1000\n-\n-#include \"PWOBase.h\"\n-#include \"PWOSequence.h\"\n-#include \n-\n-\n-class PWOList;\n-\n-class PWOListMmbr : public PWOBase\n-{\n- PWOList& _parent;\n- int _ndx;\n-public:\n- PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n- virtual ~PWOListMmbr() {};\n- PWOListMmbr& operator=(const PWOBase& other);\n- PWOListMmbr& operator=(const PWOListMmbr& other);\n- PWOListMmbr& operator=(int other);\n- PWOListMmbr& operator=(double other);\n- PWOListMmbr& operator=(const char* other);\n- PWOListMmbr& operator=(std::string other);\n-};\n-\n-class PWOList : public PWOSequence\n-{\n-public:\n- PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n- PWOList(const PWOList& other) : PWOSequence(other) {};\n- PWOList(PyObject* obj) : PWOSequence(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~PWOList() {};\n-\n- virtual PWOList& operator=(const PWOList& other) {\n- GrabRef(other);\n- return *this;\n- };\n- PWOList& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a mutable sequence\");\n- }\n- };\n- //PySequence_DelItem ##lists\n- bool delItem(int i) {\n- int rslt = PySequence_DelItem(_obj, i);\n- if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"cannot delete item\");\n- return true;\n- };\n- //PySequence_DelSlice ##lists\n- bool delSlice(int lo, int hi) {\n- int rslt = PySequence_DelSlice(_obj, lo, hi);\n- if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"cannot delete slice\");\n- return true;\n- };\n- //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n- PWOListMmbr operator [] (int i) { // can't be virtual\n- //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n- PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n- //Py_XINCREF(o);\n- //if (o == 0)\n- // Fail(PyExc_IndexError, \"index out of range\");\n- return PWOListMmbr(o, *this, i); // this increfs\n- };\n- //PySequence_SetItem ##Lists\n- void setItem(int ndx, PWOBase& val) {\n- //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n- int rslt = PyList_SetItem(_obj, ndx, val);\n- val.disOwn(); //when using PyList_SetItem, he steals my reference\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, int val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n- \n- void setItem(int ndx, double val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, char* val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, std::string val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- //PySequence_SetSlice ##Lists\n- void setSlice(int lo, int hi, const PWOSequence& slice) {\n- int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n- if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"Error setting slice\");\n- };\n-\n- //PyList_Append\n- PWOList& append(const PWOBase& other) {\n- int rslt = PyList_Append(_obj, other);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n- };\n-\n- PWOList& append(int other) {\n- PyObject* oth = PyInt_FromLong(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n- };\n-\n- PWOList& append(double other) {\n- PyObject* oth = PyFloat_FromDouble(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n- };\n-\n- PWOList& append(char* other) {\n- PyObject* oth = PyString_FromString(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n- };\n-\n- PWOList& append(std::string other) {\n- PyObject* oth = PyString_FromString(other.c_str());\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n- };\n-\n- //PyList_AsTuple\n- // problem with this is it's created on the heap\n- //virtual PWOTuple& asTuple() const {\n- // PyObject* rslt = PyList_AsTuple(_obj);\n- // PWOTuple rtrn = new PWOTuple(rslt);\n- // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n- // return *rtrn;\n- //};\n- //PyList_GetItem - inherited OK\n- //PyList_GetSlice - inherited OK\n- //PyList_Insert\n- PWOList& insert(int ndx, PWOBase& other) {\n- int rslt = PyList_Insert(_obj, ndx, other);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error inserting\");\n- };\n- return *this;\n- };\n- PWOList& insert(int ndx, int other);\n- PWOList& insert(int ndx, double other);\n- PWOList& insert(int ndx, char* other); \n- PWOList& insert(int ndx, std::string other);\n-\n- //PyList_New\n- //PyList_Reverse\n- PWOList& reverse() {\n- int rslt = PyList_Reverse(_obj);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error reversing\");\n- };\n- return *this; //HA HA - Guido can't stop me!!!\n- };\n- //PyList_SetItem - using abstract\n- //PyList_SetSlice - using abstract\n- //PyList_Size - inherited OK\n- //PyList_Sort\n- PWOList& sort() {\n- int rslt = PyList_Sort(_obj);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error sorting\");\n- };\n- return *this; //HA HA - Guido can't stop me!!!\n- };\n-};\n-\n-#endif // PWOMSEQUENCE_H_INCLUDED_\n", "added_lines": 0, "deleted_lines": 224, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMSEQUENCE_H_INCLUDED_)\n#define PWOMSEQUENCE_H_INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n#include \n\n\nclass PWOList;\n\nclass PWOListMmbr : public PWOBase\n{\n PWOList& _parent;\n int _ndx;\npublic:\n PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);\n virtual ~PWOListMmbr() {};\n PWOListMmbr& operator=(const PWOBase& other);\n PWOListMmbr& operator=(const PWOListMmbr& other);\n PWOListMmbr& operator=(int other);\n PWOListMmbr& operator=(double other);\n PWOListMmbr& operator=(const char* other);\n PWOListMmbr& operator=(std::string other);\n};\n\nclass PWOList : public PWOSequence\n{\npublic:\n PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }\n PWOList(const PWOList& other) : PWOSequence(other) {};\n PWOList(PyObject* obj) : PWOSequence(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOList() {};\n\n virtual PWOList& operator=(const PWOList& other) {\n GrabRef(other);\n return *this;\n };\n PWOList& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool delItem(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool delSlice(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOListMmbr operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return PWOListMmbr(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void setItem(int ndx, PWOBase& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, int val) {\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void setItem(int ndx, double val) {\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const PWOSequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n\n //PyList_Append\n PWOList& append(const PWOBase& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(int other) {\n PyObject* oth = PyInt_FromLong(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(double other) {\n PyObject* oth = PyFloat_FromDouble(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(char* other) {\n PyObject* oth = PyString_FromString(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n PWOList& append(std::string other) {\n PyObject* oth = PyString_FromString(other.c_str());\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n PWOList& insert(int ndx, PWOBase& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n PWOList& insert(int ndx, int other);\n PWOList& insert(int ndx, double other);\n PWOList& insert(int ndx, char* other); \n PWOList& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n PWOList& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n PWOList& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n};\n\n#endif // PWOMSEQUENCE_H_INCLUDED_\n", "methods": [], "methods_before": [ { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 97, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 103, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 109, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 116, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 132, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 143, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 154, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 165, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 202, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 214, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOList::delSlice", "long_name": "PWOList::delSlice( int lo , int hi)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 44, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOList::sort", "long_name": "PWOList::sort()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 214, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , std :: string val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 109, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( const PWOList & other)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , char * val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 103, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( PyObject * obj)", "filename": "PWOMSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 39, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOList::PWOList", "long_name": "PWOList::PWOList( int size = 0)", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 37, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator =", "long_name": "PWOList::operator =( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( char * other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 154, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , double val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 97, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::_violentTypeCheck", "long_name": "PWOList::_violentTypeCheck()", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , int val)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 91, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( double other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 143, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::delItem", "long_name": "PWOList::delItem( int i)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOList::setSlice", "long_name": "PWOList::setSlice( int lo , int hi , const PWOSequence & slice)", "filename": "PWOMSequence.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 116, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( int other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 132, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( std :: string other)", "filename": "PWOMSequence.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 165, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "PWOList::~PWOList", "long_name": "PWOList::~PWOList()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 42, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::operator [ ]", "long_name": "PWOList::operator [ ]( int i)", "filename": "PWOMSequence.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOListMmbr::~PWOListMmbr", "long_name": "PWOListMmbr::~PWOListMmbr()", "filename": "PWOMSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOList::insert", "long_name": "PWOList::insert( int ndx , PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::append", "long_name": "PWOList::append( const PWOBase & other)", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::reverse", "long_name": "PWOList::reverse()", "filename": "PWOMSequence.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 202, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWOList::setItem", "long_name": "PWOList::setItem( int ndx , PWOBase & val)", "filename": "PWOMSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#if !defined(PWOMSEQUENCE_H_INCLUDED_)", "#define PWOMSEQUENCE_H_INCLUDED_", "", "#if _MSC_VER >= 1000", "#pragma once", "#endif // _MSC_VER >= 1000", "", "#include \"PWOBase.h\"", "#include \"PWOSequence.h\"", "#include ", "", "", "class PWOList;", "", "class PWOListMmbr : public PWOBase", "{", " PWOList& _parent;", " int _ndx;", "public:", " PWOListMmbr(PyObject* obj, PWOList& parent, int ndx);", " virtual ~PWOListMmbr() {};", " PWOListMmbr& operator=(const PWOBase& other);", " PWOListMmbr& operator=(const PWOListMmbr& other);", " PWOListMmbr& operator=(int other);", " PWOListMmbr& operator=(double other);", " PWOListMmbr& operator=(const char* other);", " PWOListMmbr& operator=(std::string other);", "};", "", "class PWOList : public PWOSequence", "{", "public:", " PWOList(int size=0) : PWOSequence (PyList_New(size)) { LoseRef(_obj); }", " PWOList(const PWOList& other) : PWOSequence(other) {};", " PWOList(PyObject* obj) : PWOSequence(obj) {", " _violentTypeCheck();", " };", " virtual ~PWOList() {};", "", " virtual PWOList& operator=(const PWOList& other) {", " GrabRef(other);", " return *this;", " };", " PWOList& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mutable sequence\");", " }", " };", " //PySequence_DelItem ##lists", " bool delItem(int i) {", " int rslt = PySequence_DelItem(_obj, i);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"cannot delete item\");", " return true;", " };", " //PySequence_DelSlice ##lists", " bool delSlice(int lo, int hi) {", " int rslt = PySequence_DelSlice(_obj, lo, hi);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"cannot delete slice\");", " return true;", " };", " //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase", " PWOListMmbr operator [] (int i) { // can't be virtual", " //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid", " PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount", " //Py_XINCREF(o);", " //if (o == 0)", " // Fail(PyExc_IndexError, \"index out of range\");", " return PWOListMmbr(o, *this, i); // this increfs", " };", " //PySequence_SetItem ##Lists", " void setItem(int ndx, PWOBase& val) {", " //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid", " int rslt = PyList_SetItem(_obj, ndx, val);", " val.disOwn(); //when using PyList_SetItem, he steals my reference", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, int val) {", " int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, double val) {", " int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, char* val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, std::string val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " //PySequence_SetSlice ##Lists", " void setSlice(int lo, int hi, const PWOSequence& slice) {", " int rslt = PySequence_SetSlice(_obj, lo, hi, slice);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"Error setting slice\");", " };", "", " //PyList_Append", " PWOList& append(const PWOBase& other) {", " int rslt = PyList_Append(_obj, other);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(int other) {", " PyObject* oth = PyInt_FromLong(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(double other) {", " PyObject* oth = PyFloat_FromDouble(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(char* other) {", " PyObject* oth = PyString_FromString(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " PWOList& append(std::string other) {", " PyObject* oth = PyString_FromString(other.c_str());", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", " };", "", " //PyList_AsTuple", " // problem with this is it's created on the heap", " //virtual PWOTuple& asTuple() const {", " // PyObject* rslt = PyList_AsTuple(_obj);", " // PWOTuple rtrn = new PWOTuple(rslt);", " // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed", " // return *rtrn;", " //};", " //PyList_GetItem - inherited OK", " //PyList_GetSlice - inherited OK", " //PyList_Insert", " PWOList& insert(int ndx, PWOBase& other) {", " int rslt = PyList_Insert(_obj, ndx, other);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error inserting\");", " };", " return *this;", " };", " PWOList& insert(int ndx, int other);", " PWOList& insert(int ndx, double other);", " PWOList& insert(int ndx, char* other);", " PWOList& insert(int ndx, std::string other);", "", " //PyList_New", " //PyList_Reverse", " PWOList& reverse() {", " int rslt = PyList_Reverse(_obj);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error reversing\");", " };", " return *this; //HA HA - Guido can't stop me!!!", " };", " //PyList_SetItem - using abstract", " //PyList_SetSlice - using abstract", " //PyList_Size - inherited OK", " //PyList_Sort", " PWOList& sort() {", " int rslt = PyList_Sort(_obj);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error sorting\");", " };", " return *this; //HA HA - Guido can't stop me!!!", " };", "};", "", "#endif // PWOMSEQUENCE_H_INCLUDED_" ] } }, { "old_path": "weave/scxx/PWOMapping.h", "new_path": null, "filename": "PWOMapping.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,180 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#if !defined(PWOMAPPING_H_INCLUDED_)\n-#define PWOMAPPING_H_INCLUDED_\n-\n-#include \"PWOBase.h\"\n-#include \"PWOMSequence.h\"\n-#include \"PWONumber.h\"\n-#include \n-\n-class PWOMapping;\n-\n-class PWOMappingMmbr : public PWOBase\n-{\n- PWOMapping& _parent;\n- PyObject* _key;\n-public:\n- PWOMappingMmbr(PyObject* obj, PWOMapping& parent, PyObject* key)\n- : PWOBase(obj), _parent(parent), _key(key)\n- {\n- Py_XINCREF(_key);\n- };\n- virtual ~PWOMappingMmbr() {\n- Py_XDECREF(_key);\n- };\n- PWOMappingMmbr& operator=(const PWOBase& other);\n- PWOMappingMmbr& operator=(int other);\n- PWOMappingMmbr& operator=(double other);\n- PWOMappingMmbr& operator=(const char* other);\n- PWOMappingMmbr& operator=(std::string other);\n-};\n-\n-class PWOMapping : public PWOBase\n-{\n-public:\n- PWOMapping() : PWOBase (PyDict_New()) { LoseRef(_obj); }\n- PWOMapping(const PWOMapping& other) : PWOBase(other) {};\n- PWOMapping(PyObject* obj) : PWOBase(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~PWOMapping() {};\n-\n- virtual PWOMapping& operator=(const PWOMapping& other) {\n- GrabRef(other);\n- return *this;\n- };\n- PWOMapping& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PyMapping_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a mapping\");\n- }\n- };\n-\n- //PyMapping_GetItemString\n- //PyDict_GetItemString\n- PWOMappingMmbr operator [] (const char* key) {\n- PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n- if (rslt==0)\n- PyErr_Clear();\n- PWOString _key(key);\n- return PWOMappingMmbr(rslt, *this, _key);\n- };\n-\n- PWOMappingMmbr operator [] (std::string key) {\n- PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n- if (rslt==0)\n- PyErr_Clear();\n- PWOString _key(key.c_str());\n- return PWOMappingMmbr(rslt, *this, _key);\n- };\n- \n- //PyDict_GetItem\n- PWOMappingMmbr operator [] (PyObject* key) {\n- PyObject* rslt = PyDict_GetItem(_obj, key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return PWOMappingMmbr(rslt, *this, key);\n- };\n-\n- //PyDict_GetItem\n- PWOMappingMmbr operator [] (int key) {\n- PWONumber _key = PWONumber(key);\n- PyObject* rslt = PyDict_GetItem(_obj, _key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return PWOMappingMmbr(rslt, *this, _key);\n- };\n- \n- //PyDict_GetItem\n- PWOMappingMmbr operator [] (float key) {\n- PWONumber _key = PWONumber(key);\n- PyObject* rslt = PyDict_GetItem(_obj, _key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return PWOMappingMmbr(rslt, *this, _key);\n- };\n-\n- PWOMappingMmbr operator [] (double key) {\n- PWONumber _key = PWONumber(key);\n- PyObject* rslt = PyDict_GetItem(_obj, _key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return PWOMappingMmbr(rslt, *this, _key);\n- };\n- \n- //PyMapping_HasKey\n- bool hasKey(PyObject* key) const {\n- return PyMapping_HasKey(_obj, key)==1;\n- };\n- //PyMapping_HasKeyString\n- bool hasKey(const char* key) const {\n- return PyMapping_HasKeyString(_obj, (char*) key)==1;\n- };\n- //PyMapping_Length\n- //PyDict_Size\n- int len() const {\n- return PyMapping_Length(_obj);\n- };\n- //PyMapping_SetItemString\n- //PyDict_SetItemString\n- void setItem(const char* key, PyObject* val) {\n- int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n- if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n- };\n- //PyDict_SetItem\n- void setItem(PyObject* key, PyObject* val) const {\n- int rslt = PyDict_SetItem(_obj, key, val);\n- if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key must be hashable\");\n- };\n- //PyDict_Clear\n- void clear() {\n- PyDict_Clear(_obj);\n- };\n- //PyDict_DelItem\n- void delItem(PyObject* key) {\n- int rslt = PyMapping_DelItem(_obj, key);\n- if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key not found\");\n- };\n- //PyDict_DelItemString\n- void delItem(const char* key) {\n- int rslt = PyDict_DelItemString(_obj, (char*) key);\n- if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key not found\");\n- };\n- //PyDict_Items\n- PWOList items() const {\n- PyObject* rslt = PyMapping_Items(_obj);\n- if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get items\");\n- return LoseRef(rslt);\n- };\n- //PyDict_Keys\n- PWOList keys() const {\n- PyObject* rslt = PyMapping_Keys(_obj);\n- if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get keys\");\n- return LoseRef(rslt);\n- };\n- //PyDict_New - default constructor\n- //PyDict_Next\n- //PyDict_Values\n- PWOList values() const {\n- PyObject* rslt = PyMapping_Values(_obj);\n- if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get values\");\n- return LoseRef(rslt);\n- };\n-};\n-\n-#endif // PWOMAPPING_H_INCLUDED_\n", "added_lines": 0, "deleted_lines": 180, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOMAPPING_H_INCLUDED_)\n#define PWOMAPPING_H_INCLUDED_\n\n#include \"PWOBase.h\"\n#include \"PWOMSequence.h\"\n#include \"PWONumber.h\"\n#include \n\nclass PWOMapping;\n\nclass PWOMappingMmbr : public PWOBase\n{\n PWOMapping& _parent;\n PyObject* _key;\npublic:\n PWOMappingMmbr(PyObject* obj, PWOMapping& parent, PyObject* key)\n : PWOBase(obj), _parent(parent), _key(key)\n {\n Py_XINCREF(_key);\n };\n virtual ~PWOMappingMmbr() {\n Py_XDECREF(_key);\n };\n PWOMappingMmbr& operator=(const PWOBase& other);\n PWOMappingMmbr& operator=(int other);\n PWOMappingMmbr& operator=(double other);\n PWOMappingMmbr& operator=(const char* other);\n PWOMappingMmbr& operator=(std::string other);\n};\n\nclass PWOMapping : public PWOBase\n{\npublic:\n PWOMapping() : PWOBase (PyDict_New()) { LoseRef(_obj); }\n PWOMapping(const PWOMapping& other) : PWOBase(other) {};\n PWOMapping(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOMapping() {};\n\n virtual PWOMapping& operator=(const PWOMapping& other) {\n GrabRef(other);\n return *this;\n };\n PWOMapping& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyMapping_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mapping\");\n }\n };\n\n //PyMapping_GetItemString\n //PyDict_GetItemString\n PWOMappingMmbr operator [] (const char* key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key);\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (std::string key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n if (rslt==0)\n PyErr_Clear();\n PWOString _key(key.c_str());\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (PyObject* key) {\n PyObject* rslt = PyDict_GetItem(_obj, key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, key);\n };\n\n //PyDict_GetItem\n PWOMappingMmbr operator [] (int key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyDict_GetItem\n PWOMappingMmbr operator [] (float key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n\n PWOMappingMmbr operator [] (double key) {\n PWONumber _key = PWONumber(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return PWOMappingMmbr(rslt, *this, _key);\n };\n \n //PyMapping_HasKey\n bool hasKey(PyObject* key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n //PyMapping_HasKeyString\n bool hasKey(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n //PyMapping_Length\n //PyDict_Size\n int len() const {\n return PyMapping_Length(_obj);\n };\n //PyMapping_SetItemString\n //PyDict_SetItemString\n void setItem(const char* key, PyObject* val) {\n int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n //PyDict_SetItem\n void setItem(PyObject* key, PyObject* val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key must be hashable\");\n };\n //PyDict_Clear\n void clear() {\n PyDict_Clear(_obj);\n };\n //PyDict_DelItem\n void delItem(PyObject* key) {\n int rslt = PyMapping_DelItem(_obj, key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_DelItemString\n void delItem(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_Items\n PWOList items() const {\n PyObject* rslt = PyMapping_Items(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get items\");\n return LoseRef(rslt);\n };\n //PyDict_Keys\n PWOList keys() const {\n PyObject* rslt = PyMapping_Keys(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get keys\");\n return LoseRef(rslt);\n };\n //PyDict_New - default constructor\n //PyDict_Next\n //PyDict_Values\n PWOList values() const {\n PyObject* rslt = PyMapping_Values(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get values\");\n return LoseRef(rslt);\n };\n};\n\n#endif // PWOMAPPING_H_INCLUDED_\n", "methods": [], "methods_before": [ { "name": "PWOMappingMmbr::PWOMappingMmbr", "long_name": "PWOMappingMmbr::PWOMappingMmbr( PyObject * obj , PWOMapping & parent , PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMappingMmbr::~PWOMappingMmbr", "long_name": "PWOMappingMmbr::~PWOMappingMmbr()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( PyObject * obj)", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::~PWOMapping", "long_name": "PWOMapping::~PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 43, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOBase & other)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::_violentTypeCheck", "long_name": "PWOMapping::_violentTypeCheck()", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 54, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( const char * key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 63, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( std :: string key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( PyObject * key)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( int key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 88, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( float key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 97, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( double key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( PyObject * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( const char * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::len", "long_name": "PWOMapping::len() const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( const char * key , PyObject * val)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( PyObject * key , PyObject * val) const", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 134, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::clear", "long_name": "PWOMapping::clear()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( const char * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::items", "long_name": "PWOMapping::items() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::keys", "long_name": "PWOMapping::keys() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 163, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::values", "long_name": "PWOMapping::values() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMappingMmbr::PWOMappingMmbr", "long_name": "PWOMappingMmbr::PWOMappingMmbr( PyObject * obj , PWOMapping & parent , PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOMapping::len", "long_name": "PWOMapping::len() const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( const char * key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 63, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( const char * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( const char * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::hasKey", "long_name": "PWOMapping::hasKey( PyObject * key) const", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::keys", "long_name": "PWOMapping::keys() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 163, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMappingMmbr::~PWOMappingMmbr", "long_name": "PWOMappingMmbr::~PWOMappingMmbr()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( int key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 88, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::_violentTypeCheck", "long_name": "PWOMapping::_violentTypeCheck()", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 54, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( double key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator =", "long_name": "PWOMapping::operator =( const PWOBase & other)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::items", "long_name": "PWOMapping::items() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::clear", "long_name": "PWOMapping::clear()", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( PyObject * obj)", "filename": "PWOMapping.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOMapping::PWOMapping", "long_name": "PWOMapping::PWOMapping( const PWOMapping & other)", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::~PWOMapping", "long_name": "PWOMapping::~PWOMapping()", "filename": "PWOMapping.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 43, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( PyObject * key , PyObject * val) const", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 134, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( PyObject * key)", "filename": "PWOMapping.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::values", "long_name": "PWOMapping::values() const", "filename": "PWOMapping.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOMapping::delItem", "long_name": "PWOMapping::delItem( PyObject * key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( std :: string key)", "filename": "PWOMapping.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::operator [ ]", "long_name": "PWOMapping::operator [ ]( float key)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 97, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "PWOMapping::setItem", "long_name": "PWOMapping::setItem( const char * key , PyObject * val)", "filename": "PWOMapping.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#if !defined(PWOMAPPING_H_INCLUDED_)", "#define PWOMAPPING_H_INCLUDED_", "", "#include \"PWOBase.h\"", "#include \"PWOMSequence.h\"", "#include \"PWONumber.h\"", "#include ", "", "class PWOMapping;", "", "class PWOMappingMmbr : public PWOBase", "{", " PWOMapping& _parent;", " PyObject* _key;", "public:", " PWOMappingMmbr(PyObject* obj, PWOMapping& parent, PyObject* key)", " : PWOBase(obj), _parent(parent), _key(key)", " {", " Py_XINCREF(_key);", " };", " virtual ~PWOMappingMmbr() {", " Py_XDECREF(_key);", " };", " PWOMappingMmbr& operator=(const PWOBase& other);", " PWOMappingMmbr& operator=(int other);", " PWOMappingMmbr& operator=(double other);", " PWOMappingMmbr& operator=(const char* other);", " PWOMappingMmbr& operator=(std::string other);", "};", "", "class PWOMapping : public PWOBase", "{", "public:", " PWOMapping() : PWOBase (PyDict_New()) { LoseRef(_obj); }", " PWOMapping(const PWOMapping& other) : PWOBase(other) {};", " PWOMapping(PyObject* obj) : PWOBase(obj) {", " _violentTypeCheck();", " };", " virtual ~PWOMapping() {};", "", " virtual PWOMapping& operator=(const PWOMapping& other) {", " GrabRef(other);", " return *this;", " };", " PWOMapping& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyMapping_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mapping\");", " }", " };", "", " //PyMapping_GetItemString", " //PyDict_GetItemString", " PWOMappingMmbr operator [] (const char* key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);", " if (rslt==0)", " PyErr_Clear();", " PWOString _key(key);", " return PWOMappingMmbr(rslt, *this, _key);", " };", "", " PWOMappingMmbr operator [] (std::string key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());", " if (rslt==0)", " PyErr_Clear();", " PWOString _key(key.c_str());", " return PWOMappingMmbr(rslt, *this, _key);", " };", "", " //PyDict_GetItem", " PWOMappingMmbr operator [] (PyObject* key) {", " PyObject* rslt = PyDict_GetItem(_obj, key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return PWOMappingMmbr(rslt, *this, key);", " };", "", " //PyDict_GetItem", " PWOMappingMmbr operator [] (int key) {", " PWONumber _key = PWONumber(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return PWOMappingMmbr(rslt, *this, _key);", " };", "", " //PyDict_GetItem", " PWOMappingMmbr operator [] (float key) {", " PWONumber _key = PWONumber(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return PWOMappingMmbr(rslt, *this, _key);", " };", "", " PWOMappingMmbr operator [] (double key) {", " PWONumber _key = PWONumber(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return PWOMappingMmbr(rslt, *this, _key);", " };", "", " //PyMapping_HasKey", " bool hasKey(PyObject* key) const {", " return PyMapping_HasKey(_obj, key)==1;", " };", " //PyMapping_HasKeyString", " bool hasKey(const char* key) const {", " return PyMapping_HasKeyString(_obj, (char*) key)==1;", " };", " //PyMapping_Length", " //PyDict_Size", " int len() const {", " return PyMapping_Length(_obj);", " };", " //PyMapping_SetItemString", " //PyDict_SetItemString", " void setItem(const char* key, PyObject* val) {", " int rslt = PyMapping_SetItemString(_obj, (char*) key, val);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"Cannot add key / value\");", " };", " //PyDict_SetItem", " void setItem(PyObject* key, PyObject* val) const {", " int rslt = PyDict_SetItem(_obj, key, val);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key must be hashable\");", " };", " //PyDict_Clear", " void clear() {", " PyDict_Clear(_obj);", " };", " //PyDict_DelItem", " void delItem(PyObject* key) {", " int rslt = PyMapping_DelItem(_obj, key);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key not found\");", " };", " //PyDict_DelItemString", " void delItem(const char* key) {", " int rslt = PyDict_DelItemString(_obj, (char*) key);", " if (rslt==-1)", " Fail(PyExc_KeyError, \"Key not found\");", " };", " //PyDict_Items", " PWOList items() const {", " PyObject* rslt = PyMapping_Items(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get items\");", " return LoseRef(rslt);", " };", " //PyDict_Keys", " PWOList keys() const {", " PyObject* rslt = PyMapping_Keys(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get keys\");", " return LoseRef(rslt);", " };", " //PyDict_New - default constructor", " //PyDict_Next", " //PyDict_Values", " PWOList values() const {", " PyObject* rslt = PyMapping_Values(_obj);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"Failed to get values\");", " return LoseRef(rslt);", " };", "};", "", "#endif // PWOMAPPING_H_INCLUDED_" ] } }, { "old_path": "weave/scxx/PWONumber.h", "new_path": null, "filename": "PWONumber.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,180 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#if !defined(PWONUMBER_H_INCLUDED_)\n-#define PWONUMBER_H_INCLUDED_\n-\n-#include \"PWOBase.h\"\n-#include \"PWOSequence.h\"\n-\n-class PWONumber : public PWOBase\n-{\n-public:\n- PWONumber() : PWOBase() {};\n- PWONumber(int i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }\n- PWONumber(long i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }\n- PWONumber(unsigned long i) : PWOBase (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n- PWONumber(double d) : PWOBase (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n-\n- PWONumber(const PWONumber& other) : PWOBase(other) {};\n- PWONumber(PyObject* obj) : PWOBase(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~PWONumber() {};\n-\n- virtual PWONumber& operator=(const PWONumber& other) {\n- GrabRef(other);\n- return *this;\n- };\n- /*virtual*/ PWONumber& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PyNumber_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a number\");\n- }\n- };\n- //PyNumber_Absolute\n- PWONumber abs() const {\n- PyObject* rslt = PyNumber_Absolute(_obj);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Failed to get absolute value\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Add\n- PWONumber operator+(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Add(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for +\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_And\n- PWONumber operator&(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_And(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for &\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Coerce\n- //PyNumber_Divide\n- PWONumber operator/(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Divide(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for /\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Divmod\n- PWOSequence divmod(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Float\n- operator double () const {\n- PyObject* F = PyNumber_Float(_obj);\n- if (F==0)\n- Fail(PyExc_TypeError, \"Cannot convert to double\");\n- double r = PyFloat_AS_DOUBLE(F);\n- Py_DECREF(F);\n- return r;\n- };\n- operator float () const {\n- double rslt = (double) *this;\n- //if (rslt > INT_MAX)\n- // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n- return (float) rslt;\n- };\n- //PyNumber_Int\n- operator long () const {\n- PyObject* Int = PyNumber_Int(_obj);\n- if (Int==0)\n- Fail(PyExc_TypeError, \"Cannot convert to long\");\n- long r = PyInt_AS_LONG(Int);\n- Py_DECREF(Int);\n- return r;\n- };\n- operator int () const {\n- long rslt = (long) *this;\n- if (rslt > INT_MAX)\n- Fail(PyExc_TypeError, \"Cannot convert to an int\");\n- return (int) rslt;\n- };\n- //PyNumber_Invert\n- PWONumber operator~ () const {\n- PyObject* rslt = PyNumber_Invert(_obj);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for ~\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Long\n- //PyNumber_Lshift\n- PWONumber operator<<(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for <<\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Multiply\n- PWONumber operator*(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for *\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Negative\n- PWONumber operator- () const {\n- PyObject* rslt = PyNumber_Negative(_obj);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for unary -\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Or\n- PWONumber operator|(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Or(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for |\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Positive\n- PWONumber operator+ () const {\n- PyObject* rslt = PyNumber_Positive(_obj);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for unary +\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Remainder\n- PWONumber operator%(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for %\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Rshift\n- PWONumber operator>>(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for >>\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Subtract\n- PWONumber operator-(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for -\");\n- return LoseRef(rslt);\n- };\n- //PyNumber_Xor\n- PWONumber operator^(const PWONumber& rhs) const {\n- PyObject* rslt = PyNumber_Xor(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for ^\");\n- return LoseRef(rslt);\n- };\n-};\n-\n-#endif //PWONUMBER_H_INCLUDED_\n", "added_lines": 0, "deleted_lines": 180, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWONUMBER_H_INCLUDED_)\n#define PWONUMBER_H_INCLUDED_\n\n#include \"PWOBase.h\"\n#include \"PWOSequence.h\"\n\nclass PWONumber : public PWOBase\n{\npublic:\n PWONumber() : PWOBase() {};\n PWONumber(int i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }\n PWONumber(long i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }\n PWONumber(unsigned long i) : PWOBase (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n PWONumber(double d) : PWOBase (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n\n PWONumber(const PWONumber& other) : PWOBase(other) {};\n PWONumber(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWONumber() {};\n\n virtual PWONumber& operator=(const PWONumber& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWONumber& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyNumber_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a number\");\n }\n };\n //PyNumber_Absolute\n PWONumber abs() const {\n PyObject* rslt = PyNumber_Absolute(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Failed to get absolute value\");\n return LoseRef(rslt);\n };\n //PyNumber_Add\n PWONumber operator+(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Add(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n //PyNumber_And\n PWONumber operator&(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_And(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for &\");\n return LoseRef(rslt);\n };\n //PyNumber_Coerce\n //PyNumber_Divide\n PWONumber operator/(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Divide(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for /\");\n return LoseRef(rslt);\n };\n //PyNumber_Divmod\n PWOSequence divmod(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n return LoseRef(rslt);\n };\n //PyNumber_Float\n operator double () const {\n PyObject* F = PyNumber_Float(_obj);\n if (F==0)\n Fail(PyExc_TypeError, \"Cannot convert to double\");\n double r = PyFloat_AS_DOUBLE(F);\n Py_DECREF(F);\n return r;\n };\n operator float () const {\n double rslt = (double) *this;\n //if (rslt > INT_MAX)\n // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n return (float) rslt;\n };\n //PyNumber_Int\n operator long () const {\n PyObject* Int = PyNumber_Int(_obj);\n if (Int==0)\n Fail(PyExc_TypeError, \"Cannot convert to long\");\n long r = PyInt_AS_LONG(Int);\n Py_DECREF(Int);\n return r;\n };\n operator int () const {\n long rslt = (long) *this;\n if (rslt > INT_MAX)\n Fail(PyExc_TypeError, \"Cannot convert to an int\");\n return (int) rslt;\n };\n //PyNumber_Invert\n PWONumber operator~ () const {\n PyObject* rslt = PyNumber_Invert(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for ~\");\n return LoseRef(rslt);\n };\n //PyNumber_Long\n //PyNumber_Lshift\n PWONumber operator<<(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for <<\");\n return LoseRef(rslt);\n };\n //PyNumber_Multiply\n PWONumber operator*(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for *\");\n return LoseRef(rslt);\n };\n //PyNumber_Negative\n PWONumber operator- () const {\n PyObject* rslt = PyNumber_Negative(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary -\");\n return LoseRef(rslt);\n };\n //PyNumber_Or\n PWONumber operator|(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Or(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for |\");\n return LoseRef(rslt);\n };\n //PyNumber_Positive\n PWONumber operator+ () const {\n PyObject* rslt = PyNumber_Positive(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary +\");\n return LoseRef(rslt);\n };\n //PyNumber_Remainder\n PWONumber operator%(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for %\");\n return LoseRef(rslt);\n };\n //PyNumber_Rshift\n PWONumber operator>>(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for >>\");\n return LoseRef(rslt);\n };\n //PyNumber_Subtract\n PWONumber operator-(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for -\");\n return LoseRef(rslt);\n };\n //PyNumber_Xor\n PWONumber operator^(const PWONumber& rhs) const {\n PyObject* rslt = PyNumber_Xor(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for ^\");\n return LoseRef(rslt);\n };\n};\n\n#endif //PWONUMBER_H_INCLUDED_\n", "methods": [], "methods_before": [ { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber()", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 14, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( int i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 15, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( long i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 16, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( unsigned long i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 21, "parameters": [ "i" ], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( double d)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "d" ], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( const PWONumber & other)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( PyObject * obj)", "filename": "PWONumber.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWONumber::~PWONumber", "long_name": "PWONumber::~PWONumber()", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::operator =", "long_name": "PWONumber::operator =( const PWONumber & other)", "filename": "PWONumber.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWONumber::operator =", "long_name": "PWONumber::operator =( const PWOBase & other)", "filename": "PWONumber.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWONumber::_violentTypeCheck", "long_name": "PWONumber::_violentTypeCheck()", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::abs", "long_name": "PWONumber::abs() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator +", "long_name": "PWONumber::operator +( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator &", "long_name": "PWONumber::operator &( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator /", "long_name": "PWONumber::operator /( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::divmod", "long_name": "PWONumber::divmod( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator double", "long_name": "PWONumber::operator double() const", "filename": "PWONumber.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 78, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWONumber::operator float", "long_name": "PWONumber::operator float() const", "filename": "PWONumber.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator long", "long_name": "PWONumber::operator long() const", "filename": "PWONumber.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 93, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWONumber::operator int", "long_name": "PWONumber::operator int() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 101, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator ~ ", "long_name": "PWONumber::operator ~ () const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 108, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator < <", "long_name": "PWONumber::operator < <( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 116, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator *", "long_name": "PWONumber::operator *( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 123, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator -", "long_name": "PWONumber::operator -() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 130, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator |", "long_name": "PWONumber::operator |( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 137, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator +", "long_name": "PWONumber::operator +() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 144, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator %", "long_name": "PWONumber::operator %( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator > >", "long_name": "PWONumber::operator > >( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator -", "long_name": "PWONumber::operator -( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator ^", "long_name": "PWONumber::operator ^( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWONumber::operator %", "long_name": "PWONumber::operator %( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( int i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 15, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::divmod", "long_name": "PWONumber::divmod( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::abs", "long_name": "PWONumber::abs() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::_violentTypeCheck", "long_name": "PWONumber::_violentTypeCheck()", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator int", "long_name": "PWONumber::operator int() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 101, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( PyObject * obj)", "filename": "PWONumber.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWONumber::operator < <", "long_name": "PWONumber::operator < <( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 116, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator &", "long_name": "PWONumber::operator &( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator -", "long_name": "PWONumber::operator -() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 130, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator -", "long_name": "PWONumber::operator -( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 165, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator =", "long_name": "PWONumber::operator =( const PWONumber & other)", "filename": "PWONumber.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWONumber::operator *", "long_name": "PWONumber::operator *( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 123, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator +", "long_name": "PWONumber::operator +( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator ^", "long_name": "PWONumber::operator ^( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator float", "long_name": "PWONumber::operator float() const", "filename": "PWONumber.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( const PWONumber & other)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::~PWONumber", "long_name": "PWONumber::~PWONumber()", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( unsigned long i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 21, "parameters": [ "i" ], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::operator +", "long_name": "PWONumber::operator +() const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 144, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber()", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 14, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( double d)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "d" ], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::operator /", "long_name": "PWONumber::operator /( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator > >", "long_name": "PWONumber::operator > >( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator |", "long_name": "PWONumber::operator |( const PWONumber & rhs) const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 137, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator long", "long_name": "PWONumber::operator long() const", "filename": "PWONumber.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 93, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "PWONumber::operator =", "long_name": "PWONumber::operator =( const PWOBase & other)", "filename": "PWONumber.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWONumber::PWONumber", "long_name": "PWONumber::PWONumber( long i)", "filename": "PWONumber.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 16, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWONumber::operator ~ ", "long_name": "PWONumber::operator ~ () const", "filename": "PWONumber.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 108, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWONumber::operator double", "long_name": "PWONumber::operator double() const", "filename": "PWONumber.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 78, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#if !defined(PWONUMBER_H_INCLUDED_)", "#define PWONUMBER_H_INCLUDED_", "", "#include \"PWOBase.h\"", "#include \"PWOSequence.h\"", "", "class PWONumber : public PWOBase", "{", "public:", " PWONumber() : PWOBase() {};", " PWONumber(int i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }", " PWONumber(long i) : PWOBase (PyInt_FromLong(i)) { LoseRef(_obj); }", " PWONumber(unsigned long i) : PWOBase (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }", " PWONumber(double d) : PWOBase (PyFloat_FromDouble(d)) { LoseRef(_obj); }", "", " PWONumber(const PWONumber& other) : PWOBase(other) {};", " PWONumber(PyObject* obj) : PWOBase(obj) {", " _violentTypeCheck();", " };", " virtual ~PWONumber() {};", "", " virtual PWONumber& operator=(const PWONumber& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ PWONumber& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyNumber_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a number\");", " }", " };", " //PyNumber_Absolute", " PWONumber abs() const {", " PyObject* rslt = PyNumber_Absolute(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Failed to get absolute value\");", " return LoseRef(rslt);", " };", " //PyNumber_Add", " PWONumber operator+(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Add(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " };", " //PyNumber_And", " PWONumber operator&(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_And(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for &\");", " return LoseRef(rslt);", " };", " //PyNumber_Coerce", " //PyNumber_Divide", " PWONumber operator/(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Divide(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for /\");", " return LoseRef(rslt);", " };", " //PyNumber_Divmod", " PWOSequence divmod(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Divmod(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for divmod\");", " return LoseRef(rslt);", " };", " //PyNumber_Float", " operator double () const {", " PyObject* F = PyNumber_Float(_obj);", " if (F==0)", " Fail(PyExc_TypeError, \"Cannot convert to double\");", " double r = PyFloat_AS_DOUBLE(F);", " Py_DECREF(F);", " return r;", " };", " operator float () const {", " double rslt = (double) *this;", " //if (rslt > INT_MAX)", " // Fail(PyExc_TypeError, \"Cannot convert to a float\");", " return (float) rslt;", " };", " //PyNumber_Int", " operator long () const {", " PyObject* Int = PyNumber_Int(_obj);", " if (Int==0)", " Fail(PyExc_TypeError, \"Cannot convert to long\");", " long r = PyInt_AS_LONG(Int);", " Py_DECREF(Int);", " return r;", " };", " operator int () const {", " long rslt = (long) *this;", " if (rslt > INT_MAX)", " Fail(PyExc_TypeError, \"Cannot convert to an int\");", " return (int) rslt;", " };", " //PyNumber_Invert", " PWONumber operator~ () const {", " PyObject* rslt = PyNumber_Invert(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for ~\");", " return LoseRef(rslt);", " };", " //PyNumber_Long", " //PyNumber_Lshift", " PWONumber operator<<(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Lshift(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for <<\");", " return LoseRef(rslt);", " };", " //PyNumber_Multiply", " PWONumber operator*(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Multiply(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for *\");", " return LoseRef(rslt);", " };", " //PyNumber_Negative", " PWONumber operator- () const {", " PyObject* rslt = PyNumber_Negative(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for unary -\");", " return LoseRef(rslt);", " };", " //PyNumber_Or", " PWONumber operator|(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Or(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for |\");", " return LoseRef(rslt);", " };", " //PyNumber_Positive", " PWONumber operator+ () const {", " PyObject* rslt = PyNumber_Positive(_obj);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper type for unary +\");", " return LoseRef(rslt);", " };", " //PyNumber_Remainder", " PWONumber operator%(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Remainder(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for %\");", " return LoseRef(rslt);", " };", " //PyNumber_Rshift", " PWONumber operator>>(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Rshift(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for >>\");", " return LoseRef(rslt);", " };", " //PyNumber_Subtract", " PWONumber operator-(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Subtract(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for -\");", " return LoseRef(rslt);", " };", " //PyNumber_Xor", " PWONumber operator^(const PWONumber& rhs) const {", " PyObject* rslt = PyNumber_Xor(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for ^\");", " return LoseRef(rslt);", " };", "};", "", "#endif //PWONUMBER_H_INCLUDED_" ] } }, { "old_path": "weave/scxx/PWOSequence.h", "new_path": null, "filename": "PWOSequence.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,222 +0,0 @@\n-/******************************************** \n- copyright 1999 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n-*********************************************/\n-#if !defined(PWOSEQUENCE_H_INCLUDED_)\n-#define PWOSEQUENCE_H_INCLUDED_\n-\n-#include \n-#include \"PWOBase.h\"\n-\n-// This isn't being picked up out of PWOBase.h for some reason\n-void Fail(PyObject*, const char* msg);\n-\n-class PWOString;\n-\n-class PWOSequence : public PWOBase\n-{\n-public:\n- PWOSequence() : PWOBase() {};\n- PWOSequence(const PWOSequence& other) : PWOBase(other) {};\n- PWOSequence(PyObject* obj) : PWOBase(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~PWOSequence() {}\n-\n- virtual PWOSequence& operator=(const PWOSequence& other) {\n- GrabRef(other);\n- return *this;\n- };\n- /*virtual*/ PWOSequence& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PySequence_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a sequence\");\n- }\n- };\n- //PySequence_Concat\n- PWOSequence operator+(const PWOSequence& rhs) const {\n- PyObject* rslt = PySequence_Concat(_obj, rhs);\n- if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for +\");\n- return LoseRef(rslt);\n- };\n-\n- //PySequence_Count\n- int count(const PWOBase& value) const {\n- int rslt = PySequence_Count(_obj, value);\n- if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"failure in count\");\n- return rslt;\n- };\n-\n- int count(int value) const;\n- int count(double value) const; \n- int count(char* value) const;\n- int count(std::string value) const;\n- \n- //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n- PWOBase operator [] (int i) const { //can't be virtual\n- PyObject* o = PySequence_GetItem(_obj, i);\n- if (o == 0)\n- Fail(PyExc_IndexError, \"index out of range\");\n- return LoseRef(o);\n- };\n- //PySequence_GetSlice\n- //virtual PWOSequence& operator [] (PWSlice& x) {...};\n- PWOSequence getSlice(int lo, int hi) const {\n- PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n- if (o == 0)\n- Fail(PyExc_IndexError, \"could not obtain slice\");\n- return LoseRef(o);\n- };\n- //PySequence_In\n- bool in(const PWOBase& value) const {\n- int rslt = PySequence_In(_obj, value);\n- if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"problem in in\");\n- return (rslt==1);\n- };\n- \n- bool in(int value); \n- bool in(double value);\n- bool in(char* value);\n- bool in(std::string value);\n- \n- //PySequence_Index\n- int index(const PWOBase& value) const {\n- int rslt = PySequence_Index(_obj, value);\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"value not found\");\n- return rslt;\n- };\n- int index(int value) const;\n- int index(double value) const;\n- int index(char* value) const;\n- int index(std::string value) const; \n- \n- //PySequence_Length\n- int len() const {\n- return PySequence_Length(_obj);\n- };\n- // added length for compatibility with std::string.\n- int length() const {\n- return PySequence_Length(_obj);\n- };\n- //PySequence_Repeat\n- PWOSequence operator * (int count) const {\n- PyObject* rslt = PySequence_Repeat(_obj, count);\n- if (rslt==0)\n- Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n- return LoseRef(rslt);\n- };\n- //PySequence_Tuple\n-};\n-\n-class PWOList;\n-\n-class PWOTuple : public PWOSequence\n-{\n-public:\n- PWOTuple(int sz=0) : PWOSequence (PyTuple_New(sz)) { LoseRef(_obj); }\n- PWOTuple(const PWOTuple& other) : PWOSequence(other) { }\n- PWOTuple(PyObject* obj) : PWOSequence(obj) { _violentTypeCheck(); }\n- PWOTuple(const PWOList& list);\n- virtual ~PWOTuple() {};\n-\n- virtual PWOTuple& operator=(const PWOTuple& other) {\n- GrabRef(other);\n- return *this;\n- };\n- /*virtual*/ PWOTuple& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PyTuple_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a Python Tuple\");\n- }\n- };\n- void setItem(int ndx, PWOBase& val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, val);\n- val.disOwn(); //when using PyTuple_SetItem, he steals my reference\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n- \n- // ej: additions\n- void setItem(int ndx, int val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, double val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, char* val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void setItem(int ndx, std::string val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n- // ej: end additions\n-};\n-\n-\n-class PWOString : public PWOSequence\n-{\n-public:\n- PWOString() : PWOSequence() {};\n- PWOString(const char* s)\n- : PWOSequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n- PWOString(const char* s, int sz)\n- : PWOSequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n- PWOString(const PWOString& other)\n- : PWOSequence(other) {};\n- PWOString(PyObject* obj)\n- : PWOSequence(obj) { _violentTypeCheck(); };\n- PWOString(const PWOBase& other)\n- : PWOSequence(other) { _violentTypeCheck(); };\n- virtual ~PWOString() {};\n-\n- virtual PWOString& operator=(const PWOString& other) {\n- GrabRef(other);\n- return *this;\n- };\n- PWOString& operator=(const PWOBase& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!PyString_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a Python String\");\n- }\n- };\n- operator const char* () const {\n- return PyString_AsString(_obj);\n- };\n- static PWOString format(const PWOString& fmt, PWOTuple& args){\n- PyObject * rslt =PyString_Format(fmt, args);\n- if (rslt==0)\n- Fail(PyExc_RuntimeError, \"string format failed\");\n- return LoseRef(rslt);\n- };\n-};\n-#endif // PWOSEQUENCE_H_INCLUDED_\n", "added_lines": 0, "deleted_lines": 222, "source_code": null, "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#if !defined(PWOSEQUENCE_H_INCLUDED_)\n#define PWOSEQUENCE_H_INCLUDED_\n\n#include \n#include \"PWOBase.h\"\n\n// This isn't being picked up out of PWOBase.h for some reason\nvoid Fail(PyObject*, const char* msg);\n\nclass PWOString;\n\nclass PWOSequence : public PWOBase\n{\npublic:\n PWOSequence() : PWOBase() {};\n PWOSequence(const PWOSequence& other) : PWOBase(other) {};\n PWOSequence(PyObject* obj) : PWOBase(obj) {\n _violentTypeCheck();\n };\n virtual ~PWOSequence() {}\n\n virtual PWOSequence& operator=(const PWOSequence& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOSequence& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n //PySequence_Concat\n PWOSequence operator+(const PWOSequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n\n //PySequence_Count\n int count(const PWOBase& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase\n PWOBase operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n if (o == 0)\n Fail(PyExc_IndexError, \"index out of range\");\n return LoseRef(o);\n };\n //PySequence_GetSlice\n //virtual PWOSequence& operator [] (PWSlice& x) {...};\n PWOSequence getSlice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n Fail(PyExc_IndexError, \"could not obtain slice\");\n return LoseRef(o);\n };\n //PySequence_In\n bool in(const PWOBase& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n \n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n //PySequence_Index\n int index(const PWOBase& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n };\n // added length for compatibility with std::string.\n int length() const {\n return PySequence_Length(_obj);\n };\n //PySequence_Repeat\n PWOSequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return LoseRef(rslt);\n };\n //PySequence_Tuple\n};\n\nclass PWOList;\n\nclass PWOTuple : public PWOSequence\n{\npublic:\n PWOTuple(int sz=0) : PWOSequence (PyTuple_New(sz)) { LoseRef(_obj); }\n PWOTuple(const PWOTuple& other) : PWOSequence(other) { }\n PWOTuple(PyObject* obj) : PWOSequence(obj) { _violentTypeCheck(); }\n PWOTuple(const PWOList& list);\n virtual ~PWOTuple() {};\n\n virtual PWOTuple& operator=(const PWOTuple& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ PWOTuple& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n void setItem(int ndx, PWOBase& val) {\n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disOwn(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n // ej: additions\n void setItem(int ndx, int val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, double val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, char* val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void setItem(int ndx, std::string val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n // ej: end additions\n};\n\n\nclass PWOString : public PWOSequence\n{\npublic:\n PWOString() : PWOSequence() {};\n PWOString(const char* s)\n : PWOSequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n PWOString(const char* s, int sz)\n : PWOSequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n PWOString(const PWOString& other)\n : PWOSequence(other) {};\n PWOString(PyObject* obj)\n : PWOSequence(obj) { _violentTypeCheck(); };\n PWOString(const PWOBase& other)\n : PWOSequence(other) { _violentTypeCheck(); };\n virtual ~PWOString() {};\n\n virtual PWOString& operator=(const PWOString& other) {\n GrabRef(other);\n return *this;\n };\n PWOString& operator=(const PWOBase& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n static PWOString format(const PWOString& fmt, PWOTuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"string format failed\");\n return LoseRef(rslt);\n };\n};\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "methods": [], "methods_before": [ { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::~PWOSequence", "long_name": "PWOSequence::~PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::_violentTypeCheck", "long_name": "PWOSequence::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator +", "long_name": "PWOSequence::operator +( const PWOSequence & rhs) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator [ ]", "long_name": "PWOSequence::operator [ ]( int i) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::getSlice", "long_name": "PWOSequence::getSlice( int lo , int hi) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::len", "long_name": "PWOSequence::len() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::length", "long_name": "PWOSequence::length() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::operator *", "long_name": "PWOSequence::operator *( int count) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 111, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( int sz = 0)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 125, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 126, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 127, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::~PWOTuple", "long_name": "PWOTuple::~PWOTuple()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 129, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 131, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::_violentTypeCheck", "long_name": "PWOTuple::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , PWOBase & val)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 146, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , int val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , double val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 160, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , char * val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , std :: string val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 172, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 184, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 185, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s , int sz)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 187, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOString::~PWOString", "long_name": "PWOString::~PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 195, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 201, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::_violentTypeCheck", "long_name": "PWOString::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 206, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::operator const char *", "long_name": "PWOString::operator const char *() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 212, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOString::format", "long_name": "PWOString::format( const PWOString & fmt , PWOTuple & args)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "fmt", "args" ], "start_line": 215, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "PWOSequence::getSlice", "long_name": "PWOSequence::getSlice( int lo , int hi) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s , int sz)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 187, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 30, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::operator const char *", "long_name": "PWOString::operator const char *() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 212, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::operator =", "long_name": "PWOSequence::operator =( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 26, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::operator *", "long_name": "PWOSequence::operator *( int count) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 111, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 127, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::format", "long_name": "PWOString::format( const PWOString & fmt , PWOTuple & args)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "fmt", "args" ], "start_line": 215, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::_violentTypeCheck", "long_name": "PWOTuple::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , int val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const char * s)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 185, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOTuple::~PWOTuple", "long_name": "PWOTuple::~PWOTuple()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 129, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 126, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , double val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 160, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::~PWOSequence", "long_name": "PWOSequence::~PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOTuple::operator =", "long_name": "PWOTuple::operator =( const PWOTuple & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 131, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOString & other)", "filename": "PWOSequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , std :: string val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 172, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::count", "long_name": "PWOSequence::count( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::PWOTuple", "long_name": "PWOTuple::PWOTuple( int sz = 0)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 125, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::~PWOString", "long_name": "PWOString::~PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 195, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 184, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::len", "long_name": "PWOSequence::len() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( const PWOSequence & other)", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::index", "long_name": "PWOSequence::index( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::_violentTypeCheck", "long_name": "PWOSequence::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence( PyObject * obj)", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , char * val)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOString::PWOString", "long_name": "PWOString::PWOString( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "PWOSequence::operator +", "long_name": "PWOSequence::operator +( const PWOSequence & rhs) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOString::_violentTypeCheck", "long_name": "PWOString::_violentTypeCheck()", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 206, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::operator [ ]", "long_name": "PWOSequence::operator [ ]( int i) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOTuple::setItem", "long_name": "PWOTuple::setItem( int ndx , PWOBase & val)", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 146, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "PWOSequence::length", "long_name": "PWOSequence::length() const", "filename": "PWOSequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "PWOString::operator =", "long_name": "PWOString::operator =( const PWOBase & other)", "filename": "PWOSequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 201, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "PWOSequence::PWOSequence", "long_name": "PWOSequence::PWOSequence()", "filename": "PWOSequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 1 }, { "name": "PWOSequence::in", "long_name": "PWOSequence::in( const PWOBase & value) const", "filename": "PWOSequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 1999 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "*********************************************/", "#if !defined(PWOSEQUENCE_H_INCLUDED_)", "#define PWOSEQUENCE_H_INCLUDED_", "", "#include ", "#include \"PWOBase.h\"", "", "// This isn't being picked up out of PWOBase.h for some reason", "void Fail(PyObject*, const char* msg);", "", "class PWOString;", "", "class PWOSequence : public PWOBase", "{", "public:", " PWOSequence() : PWOBase() {};", " PWOSequence(const PWOSequence& other) : PWOBase(other) {};", " PWOSequence(PyObject* obj) : PWOBase(obj) {", " _violentTypeCheck();", " };", " virtual ~PWOSequence() {}", "", " virtual PWOSequence& operator=(const PWOSequence& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ PWOSequence& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PySequence_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a sequence\");", " }", " };", " //PySequence_Concat", " PWOSequence operator+(const PWOSequence& rhs) const {", " PyObject* rslt = PySequence_Concat(_obj, rhs);", " if (rslt==0)", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " };", "", " //PySequence_Count", " int count(const PWOBase& value) const {", " int rslt = PySequence_Count(_obj, value);", " if (rslt == -1)", " Fail(PyExc_RuntimeError, \"failure in count\");", " return rslt;", " };", "", " int count(int value) const;", " int count(double value) const;", " int count(char* value) const;", " int count(std::string value) const;", "", " //PySequence_GetItem ##lists - return PWOListMmbr (mutable) otherwise just a PWOBase", " PWOBase operator [] (int i) const { //can't be virtual", " PyObject* o = PySequence_GetItem(_obj, i);", " if (o == 0)", " Fail(PyExc_IndexError, \"index out of range\");", " return LoseRef(o);", " };", " //PySequence_GetSlice", " //virtual PWOSequence& operator [] (PWSlice& x) {...};", " PWOSequence getSlice(int lo, int hi) const {", " PyObject* o = PySequence_GetSlice(_obj, lo, hi);", " if (o == 0)", " Fail(PyExc_IndexError, \"could not obtain slice\");", " return LoseRef(o);", " };", " //PySequence_In", " bool in(const PWOBase& value) const {", " int rslt = PySequence_In(_obj, value);", " if (rslt==-1)", " Fail(PyExc_RuntimeError, \"problem in in\");", " return (rslt==1);", " };", "", " bool in(int value);", " bool in(double value);", " bool in(char* value);", " bool in(std::string value);", "", " //PySequence_Index", " int index(const PWOBase& value) const {", " int rslt = PySequence_Index(_obj, value);", " if (rslt==-1)", " Fail(PyExc_IndexError, \"value not found\");", " return rslt;", " };", " int index(int value) const;", " int index(double value) const;", " int index(char* value) const;", " int index(std::string value) const;", "", " //PySequence_Length", " int len() const {", " return PySequence_Length(_obj);", " };", " // added length for compatibility with std::string.", " int length() const {", " return PySequence_Length(_obj);", " };", " //PySequence_Repeat", " PWOSequence operator * (int count) const {", " PyObject* rslt = PySequence_Repeat(_obj, count);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"sequence repeat failed\");", " return LoseRef(rslt);", " };", " //PySequence_Tuple", "};", "", "class PWOList;", "", "class PWOTuple : public PWOSequence", "{", "public:", " PWOTuple(int sz=0) : PWOSequence (PyTuple_New(sz)) { LoseRef(_obj); }", " PWOTuple(const PWOTuple& other) : PWOSequence(other) { }", " PWOTuple(PyObject* obj) : PWOSequence(obj) { _violentTypeCheck(); }", " PWOTuple(const PWOList& list);", " virtual ~PWOTuple() {};", "", " virtual PWOTuple& operator=(const PWOTuple& other) {", " GrabRef(other);", " return *this;", " };", " /*virtual*/ PWOTuple& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyTuple_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python Tuple\");", " }", " };", " void setItem(int ndx, PWOBase& val) {", " int rslt = PyTuple_SetItem(_obj, ndx, val);", " val.disOwn(); //when using PyTuple_SetItem, he steals my reference", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " // ej: additions", " void setItem(int ndx, int val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, double val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, char* val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void setItem(int ndx, std::string val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", " // ej: end additions", "};", "", "", "class PWOString : public PWOSequence", "{", "public:", " PWOString() : PWOSequence() {};", " PWOString(const char* s)", " : PWOSequence(PyString_FromString((char* )s)) { LoseRef(_obj); }", " PWOString(const char* s, int sz)", " : PWOSequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }", " PWOString(const PWOString& other)", " : PWOSequence(other) {};", " PWOString(PyObject* obj)", " : PWOSequence(obj) { _violentTypeCheck(); };", " PWOString(const PWOBase& other)", " : PWOSequence(other) { _violentTypeCheck(); };", " virtual ~PWOString() {};", "", " virtual PWOString& operator=(const PWOString& other) {", " GrabRef(other);", " return *this;", " };", " PWOString& operator=(const PWOBase& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!PyString_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python String\");", " }", " };", " operator const char* () const {", " return PyString_AsString(_obj);", " };", " static PWOString format(const PWOString& fmt, PWOTuple& args){", " PyObject * rslt =PyString_Format(fmt, args);", " if (rslt==0)", " Fail(PyExc_RuntimeError, \"string format failed\");", " return LoseRef(rslt);", " };", "};", "#endif // PWOSEQUENCE_H_INCLUDED_" ] } } ] }, { "hash": "d60990ee6570843d678ec4f55703fffc6afde40d", "msg": "removing old files", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-28T09:00:01+00:00", "author_timezone": 0, "committer_date": "2002-09-28T09:00:01+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0b2c911fc467141ca59b1b021d42fc3441598833" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 8, "insertions": 0, "lines": 8, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/scxx/scxx2.h", "new_path": null, "filename": "scxx2.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,8 +0,0 @@\n-#include \"object.h\"\n-#include \"dict.h\"\n-#include \"tuple.h\"\n-#include \"str.h\"\n-#include \"list.h\"\n-#include \"number.h\"\n-#include \"callable.h\"\n-\n", "added_lines": 0, "deleted_lines": 8, "source_code": null, "source_code_before": "#include \"object.h\"\n#include \"dict.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"list.h\"\n#include \"number.h\"\n#include \"callable.h\"\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "#include \"object.h\"", "#include \"dict.h\"", "#include \"tuple.h\"", "#include \"str.h\"", "#include \"list.h\"", "#include \"number.h\"", "#include \"callable.h\"", "" ] } } ] }, { "hash": "61917b0532b865f31c6d4c39e6ea5519fac07c37", "msg": "converted setItem to set_item in a test script", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-29T05:31:30+00:00", "author_timezone": 0, "committer_date": "2002-09-29T05:31:30+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d60990ee6570843d678ec4f55703fffc6afde40d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 5, "insertions": 5, "lines": 10, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -129,27 +129,27 @@ def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a.setItem(1,1234);\",['a'])\n+ inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n- inline_tools.inline(\"a.setItem(1,1234);\",['a']) \n+ inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n \n # check overloaded insert(int ndx, double val) method\n- inline_tools.inline(\"a.setItem(1,123.0);\",['a'])\n+ inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n- inline_tools.inline('a.setItem(1,\"bubba\");',['a'])\n+ inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n- inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])\n+ inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n", "added_lines": 5, "deleted_lines": 5, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\nclass test_call:\n \"\"\" Need to test calling routines.\n \"\"\"\n pass\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.setItem(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.setItem(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.setItem(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.setItem(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\nclass test_call:\n \"\"\" Need to test calling routines.\n \"\"\"\n pass\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 282, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 282, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 } ], "nloc": 186, "complexity": 11, "token_count": 1321, "diff_parsed": { "added": [ " inline_tools.inline(\"a.set_item(1,1234);\",['a'])", " inline_tools.inline(\"a.set_item(1,1234);\",['a'])", " inline_tools.inline(\"a.set_item(1,123.0);\",['a'])", " inline_tools.inline('a.set_item(1,\"bubba\");',['a'])", " inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])" ], "deleted": [ " inline_tools.inline(\"a.setItem(1,1234);\",['a'])", " inline_tools.inline(\"a.setItem(1,1234);\",['a'])", " inline_tools.inline(\"a.setItem(1,123.0);\",['a'])", " inline_tools.inline('a.setItem(1,\"bubba\");',['a'])", " inline_tools.inline('a.setItem(1,std::string(\"sissy\"));',['a'])" ] } } ] }, { "hash": "52c2ef46d9c00e623d841709a07d5a02b831a677", "msg": "callable is no longer a separate converter class. It is now handled by\ncatch_all converters which convert the object to a py::object on the C++\nside of things.\n\nadded more tests for attributes on new scxx classes.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-29T07:12:11+00:00", "author_timezone": 0, "committer_date": "2002-09-29T07:12:11+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "61917b0532b865f31c6d4c39e6ea5519fac07c37" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 32, "insertions": 70, "lines": 102, "files": 4, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.6875, "modified_files": [ { "old_path": "weave/c_spec.py", "new_path": "weave/c_spec.py", "filename": "c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -343,7 +343,7 @@ def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n- '\"scxx/callable.h\"','']\n+ '']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n \n@@ -396,6 +396,8 @@ def init_info(self):\n \n #----------------------------------------------------------------------------\n # Catchall Converter\n+#\n+# catch all now handles callable objects\n #----------------------------------------------------------------------------\n class catchall_converter(scxx_converter):\n def init_info(self):\n@@ -409,21 +411,6 @@ def init_info(self):\n def type_match(self,value):\n return 1\n \n-#----------------------------------------------------------------------------\n-# Callable Converter\n-#----------------------------------------------------------------------------\n-class callable_converter(scxx_converter):\n- def init_info(self):\n- scxx_converter.init_info(self)\n- self.type_name = 'callable'\n- self.check_func = 'PyCallable_Check' \n- # probably should test for callable classes here also.\n- self.matching_types = [FunctionType,MethodType,type(len)]\n- self.c_type = 'py::callable'\n- self.to_c_return = 'py::callable(py_obj)'\n- # ref counting handled by py::callable\n- self.use_ref_count = 0\n-\n def test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n", "added_lines": 3, "deleted_lines": 16, "source_code": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '\"scxx/callable.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\n#----------------------------------------------------------------------------\n# Callable Converter\n#----------------------------------------------------------------------------\nclass callable_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'callable'\n self.check_func = 'PyCallable_Check' \n # probably should test for callable classes here also.\n self.matching_types = [FunctionType,MethodType,type(len)]\n self.c_type = 'py::callable'\n self.to_c_return = 'py::callable(py_obj)'\n # ref counting handled by py::callable\n self.use_ref_count = 0\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 403, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 411, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 414, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 418, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 401, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 416, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 427, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 315, "complexity": 47, "token_count": 1597, "diff_parsed": { "added": [ " '']", "#", "# catch all now handles callable objects" ], "deleted": [ " '\"scxx/callable.h\"','']", "#----------------------------------------------------------------------------", "# Callable Converter", "#----------------------------------------------------------------------------", "class callable_converter(scxx_converter):", " def init_info(self):", " scxx_converter.init_info(self)", " self.type_name = 'callable'", " self.check_func = 'PyCallable_Check'", " # probably should test for callable classes here also.", " self.matching_types = [FunctionType,MethodType,type(len)]", " self.c_type = 'py::callable'", " self.to_c_return = 'py::callable(py_obj)'", " # ref counting handled by py::callable", " self.use_ref_count = 0", "" ] } }, { "old_path": "weave/converters.py", "new_path": "weave/converters.py", "filename": "converters.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -17,7 +17,6 @@\n c_spec.dict_converter(),\n c_spec.tuple_converter(),\n c_spec.file_converter(),\n- c_spec.callable_converter(),\n c_spec.instance_converter(),] \n #common_spec.module_converter()]\n \n", "added_lines": 0, "deleted_lines": 1, "source_code": "\"\"\" converters.py\n\"\"\"\n\nimport common_info\nimport c_spec\n\n#----------------------------------------------------------------------------\n# The \"standard\" conversion classes\n#----------------------------------------------------------------------------\n\ndefault = [c_spec.int_converter(),\n c_spec.float_converter(),\n c_spec.complex_converter(),\n c_spec.unicode_converter(),\n c_spec.string_converter(),\n c_spec.list_converter(),\n c_spec.dict_converter(),\n c_spec.tuple_converter(),\n c_spec.file_converter(),\n c_spec.instance_converter(),] \n #common_spec.module_converter()]\n\n#----------------------------------------------------------------------------\n# If Numeric is installed, add numeric array converters to the default\n# converter list.\n#----------------------------------------------------------------------------\ntry: \n import standard_array_spec\n default.append(standard_array_spec.array_converter())\nexcept ImportError: \n pass \n\n#----------------------------------------------------------------------------\n# Add wxPython support\n#----------------------------------------------------------------------------\n\ntry: \n # this is currently safe because it doesn't import wxPython.\n import wx_spec\n default.insert(0,wx_spec.wx_converter())\nexcept IndexError: \n pass \n\n#------------------------------------------------------------------------\n# Add VTK support\n#-----------------------------------------------------------------------\n\ntry: \n import vtk_spec\n default.insert(0,vtk_spec.vtk_converter())\nexcept IndexError: \n pass\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\ndefault.append(c_spec.catchall_converter())\n\nstandard_info = [common_info.basic_module_info()]\nstandard_info += [x.generate_build_info() for x in default]\n\n#----------------------------------------------------------------------------\n# Blitz conversion classes\n#\n# same as default, but will convert Numeric arrays to blitz C++ classes \n#----------------------------------------------------------------------------\nimport blitz_spec\nblitz = [blitz_spec.array_converter()] + default\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\nblitz.append(c_spec.catchall_converter())\n", "source_code_before": "\"\"\" converters.py\n\"\"\"\n\nimport common_info\nimport c_spec\n\n#----------------------------------------------------------------------------\n# The \"standard\" conversion classes\n#----------------------------------------------------------------------------\n\ndefault = [c_spec.int_converter(),\n c_spec.float_converter(),\n c_spec.complex_converter(),\n c_spec.unicode_converter(),\n c_spec.string_converter(),\n c_spec.list_converter(),\n c_spec.dict_converter(),\n c_spec.tuple_converter(),\n c_spec.file_converter(),\n c_spec.callable_converter(),\n c_spec.instance_converter(),] \n #common_spec.module_converter()]\n\n#----------------------------------------------------------------------------\n# If Numeric is installed, add numeric array converters to the default\n# converter list.\n#----------------------------------------------------------------------------\ntry: \n import standard_array_spec\n default.append(standard_array_spec.array_converter())\nexcept ImportError: \n pass \n\n#----------------------------------------------------------------------------\n# Add wxPython support\n#----------------------------------------------------------------------------\n\ntry: \n # this is currently safe because it doesn't import wxPython.\n import wx_spec\n default.insert(0,wx_spec.wx_converter())\nexcept IndexError: \n pass \n\n#------------------------------------------------------------------------\n# Add VTK support\n#-----------------------------------------------------------------------\n\ntry: \n import vtk_spec\n default.insert(0,vtk_spec.vtk_converter())\nexcept IndexError: \n pass\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\ndefault.append(c_spec.catchall_converter())\n\nstandard_info = [common_info.basic_module_info()]\nstandard_info += [x.generate_build_info() for x in default]\n\n#----------------------------------------------------------------------------\n# Blitz conversion classes\n#\n# same as default, but will convert Numeric arrays to blitz C++ classes \n#----------------------------------------------------------------------------\nimport blitz_spec\nblitz = [blitz_spec.array_converter()] + default\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\nblitz.append(c_spec.catchall_converter())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 35, "complexity": 0, "token_count": 182, "diff_parsed": { "added": [], "deleted": [ " c_spec.callable_converter()," ] } }, { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -60,24 +60,34 @@ public:\n };\n \n // Need to change return type?\n- object attr(const char* nm) const {\n- // do we want the LoseRef\n- return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));\n+ object attr(const char* nm) const { \n+ PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n+ if (!val)\n+ throw 1;\n+ return object(LoseRef(val)); \n };\n+\n object attr(std::string nm) const {\n- // do we want the LoseRef\n- return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));\n+ return attr(nm.c_str());\n };\n+\n object attr(const object& nm) const {\n- // do we want the LoseRef\n- return object(LoseRef(PyObject_GetAttr(_obj, nm)));\n+ PyObject* val = PyObject_GetAttr(_obj, nm);\n+ if (!val)\n+ throw 1;\n+ return object(LoseRef(val)); \n }; \n \n- int set_attr(const char* nm, object& val) {\n- return PyObject_SetAttrString(_obj, (char*) nm, val);\n+ void set_attr(const char* nm, object& val) {\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n+ if (res == -1)\n+ throw 1;\n };\n- int set_attr(PyObject* nm, object& val) {\n- return PyObject_SetAttr(_obj, nm, val);\n+ \n+ void set_attr(const object& nm, object& val) {\n+ int res = PyObject_SetAttr(_obj, nm, val);\n+ if (res == -1)\n+ throw 1;\n };\n \n object mcall(const char* nm);\n", "added_lines": 21, "deleted_lines": 11, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));\n };\n object attr(std::string nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));\n };\n object attr(const object& nm) const {\n // do we want the LoseRef\n return object(LoseRef(PyObject_GetAttr(_obj, nm)));\n }; \n \n int set_attr(const char* nm, object& val) {\n return PyObject_SetAttrString(_obj, (char*) nm, val);\n };\n int set_attr(PyObject* nm, object& val) {\n return PyObject_SetAttr(_obj, nm, val);\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 55, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 70, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 81, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 87, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 118, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 125, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 128, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 131, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 137, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 155, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 158, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 164, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 55, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "nm" ], "start_line": 63, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "nm", "val" ], "start_line": 76, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 79, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 101, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 108, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 127, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 142, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 145, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 154, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 70, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 81, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( PyObject * nm , object & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "nm", "val" ], "start_line": 79, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 87, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 130, "complexity": 38, "token_count": 880, "diff_parsed": { "added": [ " object attr(const char* nm) const {", " PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);", " if (!val)", " throw 1;", " return object(LoseRef(val));", "", " return attr(nm.c_str());", "", " PyObject* val = PyObject_GetAttr(_obj, nm);", " if (!val)", " throw 1;", " return object(LoseRef(val));", " void set_attr(const char* nm, object& val) {", " int res = PyObject_SetAttrString(_obj, (char*) nm, val);", " if (res == -1)", " throw 1;", "", " void set_attr(const object& nm, object& val) {", " int res = PyObject_SetAttr(_obj, nm, val);", " if (res == -1)", " throw 1;" ], "deleted": [ " object attr(const char* nm) const {", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm)));", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttrString(_obj, (char*) nm.c_str())));", " // do we want the LoseRef", " return object(LoseRef(PyObject_GetAttr(_obj, nm)));", " int set_attr(const char* nm, object& val) {", " return PyObject_SetAttrString(_obj, (char*) nm, val);", " int set_attr(PyObject* nm, object& val) {", " return PyObject_SetAttr(_obj, nm, val);" ] } }, { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -266,16 +266,58 @@ def check_count(self):\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n-class test_call:\n- \"\"\" Need to test calling routines.\n- \"\"\"\n- pass\n+# test class used for testing python class access from C++.\n+class foo:\n+ def bar(self):\n+ return \"bar results\"\n+\n+class str_obj:\n+ def __str__(self):\n+ return \"b\"\n+\n+class test_object_attr(unittest.TestCase):\n+\n+ def generic_attr(self,code,args=['a']):\n+ a = foo()\n+ a.b = 12345\n+ \n+ before = sys.getrefcount(a.b)\n+ res = inline_tools.inline(code,args)\n+ assert res == a.b\n+ del res\n+ after = sys.getrefcount(a.b)\n+ print before, after\n+ assert after == before\n+\n+ def check_char(self):\n+ self.generic_attr('return_val = a.attr(\"b\").disown();')\n+\n+ def check_string(self):\n+ self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n+\n+ def check_obj(self):\n+ code = \"\"\"\n+ py::str name = py::str(\"b\");\n+ return_val = a.attr(name).disown();\n+ \"\"\" \n+ self.generic_attr(code,['a'])\n+ \n+class test_attr_call(unittest.TestCase):\n+\n+ def check_call(self):\n+ a = foo() \n+ res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n+ assert res == \"bar results\"\n+\n+ \n \n def test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n+ suites.append( makeSuite(test_object_attr,'check_'))\n+ suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n \n", "added_lines": 46, "deleted_lines": 4, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n print before, after\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\nclass test_call:\n \"\"\" Need to test calling routines.\n \"\"\"\n pass\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 69, "parameters": [ "self", "code", "args" ], "start_line": 280, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 292, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 298, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 307, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 9, "complexity": 2, "token_count": 63, "parameters": [ "level" ], "start_line": 314, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 324, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 282, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 69, "parameters": [ "self", "code", "args" ], "start_line": 280, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 307, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 9, "complexity": 2, "token_count": 63, "parameters": [ "level" ], "start_line": 314, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 298, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 292, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 216, "complexity": 18, "token_count": 1516, "diff_parsed": { "added": [ "# test class used for testing python class access from C++.", "class foo:", " def bar(self):", " return \"bar results\"", "", "class str_obj:", " def __str__(self):", " return \"b\"", "", "class test_object_attr(unittest.TestCase):", "", " def generic_attr(self,code,args=['a']):", " a = foo()", " a.b = 12345", "", " before = sys.getrefcount(a.b)", " res = inline_tools.inline(code,args)", " assert res == a.b", " del res", " after = sys.getrefcount(a.b)", " print before, after", " assert after == before", "", " def check_char(self):", " self.generic_attr('return_val = a.attr(\"b\").disown();')", "", " def check_string(self):", " self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')", "", " def check_obj(self):", " code = \"\"\"", " py::str name = py::str(\"b\");", " return_val = a.attr(name).disown();", " \"\"\"", " self.generic_attr(code,['a'])", "", "class test_attr_call(unittest.TestCase):", "", " def check_call(self):", " a = foo()", " res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])", " assert res == \"bar results\"", "", "", " suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_attr_call,'check_'))" ], "deleted": [ "class test_call:", " \"\"\" Need to test calling routines.", " \"\"\"", " pass" ] } } ] }, { "hash": "e42148d6aadf52a9949f4aeaa6343ed0281ff5a3", "msg": "added casting to int float double and std::string for py::object.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-29T08:07:14+00:00", "author_timezone": 0, "committer_date": "2002-09-29T08:07:14+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "52c2ef46d9c00e623d841709a07d5a02b831a677" ], "project_name": "repo_copy", "project_path": "/tmp/tmp50rh0slj/repo_copy", "deletions": 1, "insertions": 105, "lines": 106, "files": 2, "dmm_unit_size": 0.4731182795698925, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -52,6 +52,29 @@ public:\n operator PyObject* () const {\n return _obj;\n };\n+ \n+ operator int () const {\n+ if (!PyInt_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to integer\");\n+ return PyInt_AsLong(_obj);\n+ }; \n+ operator float () const {\n+ if (!PyFloat_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to double\");\n+ return (float) PyFloat_AsDouble(_obj);\n+ }; \n+ operator double () const {\n+ if (!PyFloat_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to double\");\n+ return PyFloat_AsDouble(_obj);\n+ }; \n+\n+ operator std::string () const {\n+ if (!PyString_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n+ return std::string(PyString_AsString(_obj));\n+ }; \n+ \n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n", "added_lines": 23, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n\n operator std::string () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n \n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 56, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 61, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 66, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 72, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 78, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 97, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 104, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 110, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 137, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 178, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 181, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 187, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 55, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 58, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 63, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 70, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 81, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 87, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 118, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 125, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 128, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 131, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 137, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 155, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 158, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 164, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 66, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 72, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 56, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 61, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 150, "complexity": 46, "token_count": 1006, "diff_parsed": { "added": [ "", " operator int () const {", " if (!PyInt_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to integer\");", " return PyInt_AsLong(_obj);", " };", " operator float () const {", " if (!PyFloat_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to double\");", " return (float) PyFloat_AsDouble(_obj);", " };", " operator double () const {", " if (!PyFloat_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to double\");", " return PyFloat_AsDouble(_obj);", " };", "", " operator std::string () const {", " if (!PyString_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to std::string\");", " return std::string(PyString_AsString(_obj));", " };", "" ], "deleted": [] } }, { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -266,6 +266,87 @@ def check_count(self):\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n+ def check_access_speed(self):\n+ N = 1000000\n+ print 'list access -- val = a[i] for N =', N\n+ a = [0] * N\n+ val = 0\n+ t1 = time.time()\n+ for i in xrange(N):\n+ val = a[i]\n+ t2 = time.time()\n+ print 'python1:', t2 - t1\n+ t1 = time.time()\n+ for i in a:\n+ val = i\n+ t2 = time.time()\n+ print 'python2:', t2 - t1\n+ \n+ code = \"\"\"\n+ const int N = a.length();\n+ py::object val;\n+ for(int i=0; i < N; i++)\n+ val = a[i];\n+ \"\"\"\n+ # compile not included in timing \n+ inline_tools.inline(code,['a']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+\n+ def check_access_set_speed(self):\n+ N = 1000000\n+ print 'list access/set -- b[i] = a[i] for N =', N \n+ a = [0] * N\n+ b = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ b[i] = a[i]\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n+ \n+ a = [0] * N\n+ b = [1] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ for(int i=0; i < N; i++)\n+ b[i] = a[i]; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert b == a \n+ \n+class test_object_cast(unittest.TestCase):\n+ def check_int_cast(self):\n+ code = \"\"\"\n+ py::object val = py::number(1);\n+ int raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_double_cast(self):\n+ code = \"\"\"\n+ py::object val = py::number(1.0);\n+ double raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_float_cast(self):\n+ code = \"\"\"\n+ py::object val = py::number(1.0);\n+ float raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_string_cast(self):\n+ code = \"\"\"\n+ py::object val = py::str(\"hello\");\n+ std::string raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ \n # test class used for testing python class access from C++.\n class foo:\n def bar(self):\n@@ -286,7 +367,6 @@ def generic_attr(self,code,args=['a']):\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n- print before, after\n assert after == before\n \n def check_char(self):\n@@ -316,6 +396,7 @@ def test_suite(level=1):\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n+ suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n", "added_lines": 82, "deleted_lines": 1, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = py::number(1);\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = py::str(\"hello\");\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n print before, after\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 269, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 298, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 325, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 343, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 352, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 361, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 372, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 375, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 387, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 10, "complexity": 2, "token_count": 74, "parameters": [ "level" ], "start_line": 394, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 405, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 69, "parameters": [ "self", "code", "args" ], "start_line": 280, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 292, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 298, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 307, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 9, "complexity": 2, "token_count": 63, "parameters": [ "level" ], "start_line": 314, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 324, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 69, "parameters": [ "self", "code", "args" ], "start_line": 280, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 325, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 269, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 298, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 343, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 10, "complexity": 2, "token_count": 74, "parameters": [ "level" ], "start_line": 394, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 290, "complexity": 27, "token_count": 1848, "diff_parsed": { "added": [ " def check_access_speed(self):", " N = 1000000", " print 'list access -- val = a[i] for N =', N", " a = [0] * N", " val = 0", " t1 = time.time()", " for i in xrange(N):", " val = a[i]", " t2 = time.time()", " print 'python1:', t2 - t1", " t1 = time.time()", " for i in a:", " val = i", " t2 = time.time()", " print 'python2:', t2 - t1", "", " code = \"\"\"", " const int N = a.length();", " py::object val;", " for(int i=0; i < N; i++)", " val = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a'])", " t1 = time.time()", " inline_tools.inline(code,['a'])", " t2 = time.time()", " print 'weave:', t2 - t1", "", " def check_access_set_speed(self):", " N = 1000000", " print 'list access/set -- b[i] = a[i] for N =', N", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " for i in xrange(N):", " b[i] = a[i]", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [0] * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == a", "", "class test_object_cast(unittest.TestCase):", " def check_int_cast(self):", " code = \"\"\"", " py::object val = py::number(1);", " int raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_double_cast(self):", " code = \"\"\"", " py::object val = py::number(1.0);", " double raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_float_cast(self):", " code = \"\"\"", " py::object val = py::number(1.0);", " float raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_string_cast(self):", " code = \"\"\"", " py::object val = py::str(\"hello\");", " std::string raw_val = val;", " \"\"\"", " inline_tools.inline(code)", "", " suites.append( makeSuite(test_object_cast,'check_'))" ], "deleted": [ " print before, after" ] } } ] } ]