Dean Giberson avatar Dean Giberson committed d515287 Merge

Merge remote-tracking branch 'upstream/master'

Comments (0)

Files changed (329)

blender/CMakeLists.txt

 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
 option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
-option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)
-mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
+# option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)  # this is now only available in a branch
+# mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
 
 # Image format support
 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
 # On Unix:
 #   cmake ../blender \
-#         -D PYTHON_VERSION=3.2 \
-#         -D PYTHON_INCLUDE_DIR=/opt/py32/include/python3.2d \
-#         -D PYTHON_LIBRARY=/opt/py32/lib/libpython3.2d.so
+#         -D PYTHON_VERSION=3.3 \
+#         -D PYTHON_INCLUDE_DIR=/opt/py33/include/python3.3d \
+#         -D PYTHON_LIBRARY=/opt/py33/lib/libpython3.3d.so
 #
 # On Macs:
 #   cmake ../blender \
-#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
-#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
+#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3 \
+#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config \
 #         -G Xcode
 #
 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
 	find_package_wrapper(Freetype REQUIRED)
 
 	if(WITH_PYTHON)
-		# No way to set py32. remove for now.
+		# No way to set py33. remove for now.
 		# find_package(PythonLibs)
 
 		# Use our own instead, since wothout py is such a rare case,
 				                OUTPUT_STRIP_TRAILING_WHITESPACE)
 				string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
 			endif()
-			message(STATUS "LLVM library  = ${LLVM_LIBRARY}")
 		else()
 			message(FATAL_ERROR "LLVM not found.")
 		endif()
 
 		# Setup 64bit and 64bit windows systems
 		if(WITH_MINGW64)
-			message("Set 64 bit compiler for MinGW.")
+			message("Compiling for 64 bit with MinGW-w64.")
 			set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
 		endif()
 	else()
 	if(WITH_CYCLES_OSL)
 		set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
 	
-		message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-	
 		find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
 		find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
 		find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
 	
 		if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
 			set(OSL_FOUND TRUE)
-			message(STATUS "OSL includes = ${OSL_INCLUDES}")
-			message(STATUS "OSL library = ${OSL_LIBRARIES}")
-			message(STATUS "OSL compiler = ${OSL_COMPILER}")
 		else()
 			message(STATUS "OSL not found")
 		endif()
 
 		if(WITH_PYTHON)
 			# normally cached but not since we include them with blender
-			set(PYTHON_VERSION 3.2) # CACHE STRING)
+			if(MSVC10)
+				set(PYTHON_VERSION 3.2) # CACHE STRING)
+			else()
+				set(PYTHON_VERSION 3.3) # CACHE STRING)
+			endif()
+
 			set_lib_path(PYTHON "python")
-			set(PYTHON_LIBRARY ${PYTHON}/lib/python32.lib) #CACHE FILEPATH
+			STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
+			set(PYTHON_LIBRARY ${PYTHON}/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) #CACHE FILEPATH
+			unset(_PYTHON_VERSION_NO_DOTS)
+
 			#Shared includes for both vc2008 and vc2010
 			set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
 
 		#comes with own pthread library
 		if(NOT WITH_MINGW64)
 			set(PTHREADS ${LIBDIR}/pthreads)
-			set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
+			#set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
 			set(PTHREADS_LIBPATH ${PTHREADS}/lib)
 			set(PTHREADS_LIBRARIES pthreadGC2)
 		endif()
 
 		if(WITH_PYTHON)
 			# normally cached but not since we include them with blender
-			set(PYTHON_VERSION 3.2) #  CACHE STRING)
+			set(PYTHON_VERSION 3.3) #  CACHE STRING)
 			set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
-			set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
+			set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib")  # CACHE FILEPATH)
 
 			# uncached vars
 			set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
 		find_library(LLVM_LIBRARY
 		             NAMES LLVMAnalysis # first of a whole bunch of libs to get
 		             PATHS ${LLVM_LIB_DIR})
-		message(STATUS "LLVM version  = ${LLVM_VERSION}")
-		message(STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
-		message(STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")
 
 		if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
 			if(LLVM_STATIC)
 				                OUTPUT_STRIP_TRAILING_WHITESPACE)
 				string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
 			endif()
-			message(STATUS "LLVM library  = ${LLVM_LIBRARY}")
 		else()
 			message(FATAL_ERROR "LLVM not found.")
 		endif()
 	if(WITH_CYCLES_OSL)
 		set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
 	
-		message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-	
 		find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
 		find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
 		find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
 	
 		if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
 			set(OSL_FOUND TRUE)
-			message(STATUS "OSL includes = ${OSL_INCLUDES}")
-			message(STATUS "OSL library = ${OSL_LIBRARIES}")
-			message(STATUS "OSL compiler = ${OSL_COMPILER}")
 		else()
 			message(STATUS "OSL not found")
 		endif()

blender/SConstruct

         env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
         env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
 
+    # Trying to get rid of eventually clashes, we export some explicite as local symbols		
+    env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
+
 if env['WITH_BF_OPENMP'] == 1:
         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
                 env['CCFLAGS'].append('/openmp')

blender/build_files/cmake/cmake_consistency_check.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_netbeans_project.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_qtcreator_project.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_static_check_clang_array.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_static_check_cppcheck.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_static_check_smatch.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_static_check_sparse.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/cmake_static_check_splint.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/cmake/example_scripts/make_quicky.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ##### BEGIN GPL LICENSE BLOCK #####
 #

blender/build_files/cmake/project_info.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/build_files/scons/config/freebsd7-config.py

 BF_PYTHON_ABI_FLAGS = ''
 BF_PYTHON = '/usr/local'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'

blender/build_files/scons/config/freebsd8-config.py

 BF_PYTHON_ABI_FLAGS = ''
 BF_PYTHON = '/usr/local'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'

blender/build_files/scons/config/freebsd9-config.py

 BF_PYTHON_ABI_FLAGS = ''
 BF_PYTHON = '/usr/local'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'

blender/build_files/scons/config/linuxcross-config.py

 LIBDIR = '${LCGDIR}'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'

blender/build_files/scons/config/win32-mingw-config.py

 LIBDIR = "${LCGDIR}"
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
-BF_PYTHON_DLL = 'python32'
+BF_PYTHON_DLL = 'python33'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}.a'
 

blender/build_files/scons/config/win32-vc-config.py

 BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python32'
+BF_PYTHON_LIB = 'python33'
 BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 

blender/build_files/scons/config/win64-mingw-config.py

 LIBDIR = "${LCGDIR}"
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 WITH_BF_STATICPYTHON = False
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
-BF_PYTHON_DLL = 'python32'
+BF_PYTHON_DLL = 'python33'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 
 WITH_BF_OPENAL = True

blender/build_files/scons/config/win64-vc-config.py

 BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '3.2'
+BF_PYTHON_VERSION = '3.3'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python32'
+BF_PYTHON_LIB = 'python33'
 BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 

blender/build_files/scons/tools/Blender.py

         libincs += Split(lenv['BF_FFTW3_LIBPATH'])
         if lenv['WITH_BF_STATICFFTW3']:
             statlibs += Split(lenv['BF_FFTW3_LIB_STATIC'])
+    '''
     if lenv['WITH_BF_ELTOPO']:
         libincs += Split(lenv['BF_LAPACK_LIBPATH'])
         if lenv['WITH_BF_STATICLAPACK']:
-		    statlibs += Split(lenv['BF_LAPACK_LIB_STATIC'])        
+            statlibs += Split(lenv['BF_LAPACK_LIB_STATIC'])
+    '''
     if lenv['WITH_BF_FFMPEG'] and lenv['WITH_BF_STATICFFMPEG']:
         statlibs += Split(lenv['BF_FFMPEG_LIB_STATIC'])
     if lenv['WITH_BF_INTERNATIONAL']:
         syslibs += Split(lenv['BF_SNDFILE_LIB'])
     if lenv['WITH_BF_FFTW3'] and not lenv['WITH_BF_STATICFFTW3']:
         syslibs += Split(lenv['BF_FFTW3_LIB'])
+    '''
     if lenv['WITH_BF_ELTOPO']:
         syslibs += Split(lenv['BF_LAPACK_LIB'])
+    '''
     if lenv['WITH_BF_SDL']:
         syslibs += Split(lenv['BF_SDL_LIB'])
     if not lenv['WITH_BF_STATICOPENGL']:

blender/build_files/scons/tools/btools.py

             'WITH_BF_ICONV', 'BF_ICONV', 'BF_ICONV_INC', 'BF_ICONV_LIB', 'BF_ICONV_LIBPATH',
             'WITH_BF_GAMEENGINE',
             'WITH_BF_BULLET', 'BF_BULLET', 'BF_BULLET_INC', 'BF_BULLET_LIB',
-            'WITH_BF_ELTOPO', 'BF_LAPACK', 'BF_LAPACK_LIB', 'BF_LAPACK_LIBPATH', 'BF_LAPACK_LIB_STATIC',
+            # 'WITH_BF_ELTOPO',  # now only available in a branch
+            'BF_LAPACK', 'BF_LAPACK_LIB', 'BF_LAPACK_LIBPATH', 'BF_LAPACK_LIB_STATIC',
             'BF_WINTAB', 'BF_WINTAB_INC',
             'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH', 'BF_FREETYPE_LIB_STATIC', 'WITH_BF_FREETYPE_STATIC',
             'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
         (BoolVariable('WITH_BF_GAMEENGINE', 'Build with gameengine' , False)),
 
         (BoolVariable('WITH_BF_BULLET', 'Use Bullet if true', True)),
-        
-        (BoolVariable('WITH_BF_ELTOPO', 'Use Eltopo collision library if true', False)),
+        # (BoolVariable('WITH_BF_ELTOPO', 'Use Eltopo collision library if true', False)),  # this is now only available in a branch
         ('BF_LAPACK', 'LAPACK base path', ''),
         ('BF_LAPACK_LIB', 'LAPACK library', ''),
         ('BF_LAPACK_LIB_STATIC', 'LAPACK library', ''),

blender/doc/blender_file_format/BlendFileDnaExporter_25.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/doc/blender_file_format/BlendFileReader.py

-#!/usr/bin/env python3.2
+#!/usr/bin/env python3
 
 # ***** BEGIN GPL LICENSE BLOCK *****
 #

blender/doc/python_api/rst/bge.logic.rst

 .. data:: KX_SENSOR_ACTIVE
 .. data:: KX_SENSOR_JUST_DEACTIVATED
 
--------------
+---------------
 Armature Sensor
--------------
+---------------
 
 .. _armaturesensor-type:
 
 .. data:: KX_ACTIONACT_LOOPEND
 .. data:: KX_ACTIONACT_PROPERTY
 
----------------
+-----------------
 Armature Actuator
----------------
+-----------------
 
  .. _armatureactuator-constants-type:
    
 .. data:: KX_ACT_ARMATURE_ENABLE
 
   Enable the constraint.
-		
+
   :value: 1
 
 .. data:: KX_ACT_ARMATURE_DISABLE
 
   Disable the constraint (runtime constraint values are not updated).
-		
+
   :value: 2
 
 .. data:: KX_ACT_ARMATURE_SETTARGET
 
    :value: 6
 
---------------
+-----------------
 Steering Actuator
---------------
+-----------------
 
 .. _logic-steering-actuator:
 
   :value: 6
 
 
-----------------
+-------------------
 Armature Constraint
-----------------
+-------------------
 .. _armatureconstraint-constants-type:
 
 See :class:`bge.types.BL_ArmatureConstraint.type`
 .. data:: KX_INPUT_ACTIVE
 .. data:: KX_INPUT_JUST_RELEASED
 
-------------
+-------------
 KX_GameObject
------------
+-------------
 .. _gameobject-playaction-mode:
 
 See :class:`bge.types.KX_GameObject.playAction`
 .. data:: KX_MOUSE_BUT_MIDDLE
 .. data:: KX_MOUSE_BUT_RIGHT
 
-------------
+--------------------------
 Navigation Mesh Draw Modes
-------------
+--------------------------
 
 .. _navmesh-draw-mode:
 
 .. data:: KX_STATE_OP_CLR
 
    Substract bits to state mask
-   
+
    :value: 0
 
 .. data:: KX_STATE_OP_CPY
 
    Copy state mask
-   
+
    :value: 1
    
 .. data:: KX_STATE_OP_NEG
 
    Invert bits to state mask
-   
+
    :value: 2
-   
+
 .. data:: KX_STATE_OP_SET
 
    Add bits to state mask
-   
+
    :value: 3
-   
+
 .. _Two-D-FilterActuator-mode:

blender/doc/python_api/rst_from_bmesh_opdefines.py

+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+# This is a quite stupid script which extracts bmesh api docs from
+# 'bmesh_opdefines.c' in order to avoid having to add a lot of introspection
+# data access into the api.
+#
+# The script is stupid becase it makes assumptions about formatting...
+# that each arg has its own line, that comments above or directly after will be __doc__ etc...
+#
+# We may want to replace this script with something else one day but for now its good enough.
+# if it needs large updates it may be better to rewrite using a real parser or
+# add introspection into bmesh.ops.
+# - campbell
+
+import os
+
+CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
+SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(CURRENT_DIR, "..", ".."))))
+FILE_OP_DEFINES_C = os.path.join(SOURCE_DIR, "source", "blender", "bmesh", "intern", "bmesh_opdefines.c")
+OUT_RST = os.path.join(CURRENT_DIR, "rst", "bmesh.ops.rst")
+
+HEADER = r"""
+BMesh Operators (bmesh.ops)
+===========================
+
+.. module:: bmesh.ops
+
+This module gives access to low level bmesh operations.
+
+Most operators take input and return output, they can be chained together
+to perform useful operations.
+
+.. note::
+
+   This API us new in 2.65 and not yet well tested.
+
+
+"""
+
+
+def main():
+    fsrc = open(FILE_OP_DEFINES_C, 'r', encoding="utf-8")
+
+    blocks = []
+    
+    is_block = False
+    is_comment = False  # /* global comments only */
+    
+    comment_ctx = None
+    block_ctx = None
+
+    for l in fsrc:
+        l = l[:-1]
+        # weak but ok
+        if ("BMOpDefine" in l and l.split()[1] == "BMOpDefine") and not "bmo_opdefines[]" in l:
+            is_block = True
+            block_ctx = []
+            blocks.append((comment_ctx, block_ctx))
+        elif l.strip().startswith("/*"):
+            is_comment = True
+            comment_ctx = []
+        
+        if is_block:
+            if l.strip().startswith("//"):
+                pass
+            else:
+                # remove c++ comment if we have one
+                cpp_comment = l.find("//")
+                if cpp_comment != -1:
+                    l = l[:cpp_comment]
+
+                block_ctx.append(l)
+            
+            if l.strip() == "};":
+                is_block = False
+                comment_ctx = None
+        
+        if is_comment:
+            c_comment_start = l.find("/*")
+            if c_comment_start != -1:
+                l = l[c_comment_start + 2:]
+
+            c_comment_end = l.find("*/")
+            if c_comment_end != -1:
+                l = l[:c_comment_end]
+
+                is_comment = False
+            comment_ctx.append(l)
+
+    fsrc.close()
+    del fsrc
+
+
+   # namespace hack
+    vars = (
+        "BMO_OP_SLOT_ELEMENT_BUF",
+        "BMO_OP_SLOT_BOOL",
+        "BMO_OP_SLOT_FLT",
+        "BMO_OP_SLOT_INT",
+        "BMO_OP_SLOT_MAT",
+        "BMO_OP_SLOT_VEC",
+        "BMO_OP_SLOT_PTR",
+        "BMO_OP_SLOT_MAPPING",
+        
+        "BMO_OP_SLOT_SUBTYPE_MAP_ELEM",
+        "BMO_OP_SLOT_SUBTYPE_MAP_BOOL",
+        "BMO_OP_SLOT_SUBTYPE_MAP_INT",
+        "BMO_OP_SLOT_SUBTYPE_MAP_FLT",
+        "BMO_OP_SLOT_SUBTYPE_MAP_EMPTY",
+        "BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL",
+
+        "BMO_OP_SLOT_SUBTYPE_PTR_SCENE",
+        "BMO_OP_SLOT_SUBTYPE_PTR_OBJECT",
+        "BMO_OP_SLOT_SUBTYPE_PTR_MESH",
+        "BMO_OP_SLOT_SUBTYPE_PTR_BMESH",
+
+        "BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE",
+
+        "BM_VERT",
+        "BM_EDGE",
+        "BM_FACE",
+
+        "BMO_OP_FLAG_UNTAN_MULTIRES",
+    )
+    vars_dict = {}
+    for i, v in enumerate(vars):
+        vars_dict[v] = (1 << i)
+    globals().update(vars_dict)
+    # reverse lookup
+    vars_dict_reverse = {v: k for k, v in vars_dict.items()}
+    # end namespace hack
+
+    blocks_py = []
+    for comment, b in blocks:
+        # magic, translate into python
+        b[0] = b[0].replace("static BMOpDefine ", "")
+        
+        for i, l in enumerate(b):
+            l = l.strip()
+            l = l.replace("{", "(")
+            l = l.replace("}", ")")
+            
+            if l.startswith("/*"):
+                l = l.replace("/*", "'''own <")
+            else:
+                l = l.replace("/*", "'''inline <")
+            l = l.replace("*/", ">''',")
+            
+            # exec func. eg: bmo_rotate_edges_exec,
+            if l.startswith("bmo_") and l.endswith("_exec,"):
+                l = "None,"
+            b[i] = l
+            
+        #for l in b:
+        #    print(l)
+
+        text = "\n".join(b)
+        global_namespace = {
+            "__file__": "generated",
+            "__name__": "__main__",
+        }
+        
+        global_namespace.update(vars_dict)
+
+        text_a, text_b = text.split("=", 1)
+        text = "result = " + text_b
+        exec(compile(text, "generated", 'exec'), global_namespace)
+        # print(global_namespace["result"])
+        blocks_py.append((comment, global_namespace["result"]))
+
+
+    # ---------------------
+    # Now convert into rst.
+    fout = open(OUT_RST, 'w', encoding="utf-8")
+    fw = fout.write
+    fw(HEADER)
+    for comment, b in blocks_py:
+        args_in = None
+        args_out = None
+        for member in b[1:]:
+            if type(member) == tuple:
+                if args_in is None:
+                    args_in = member
+                elif args_out is None:
+                    args_out = member
+                    break
+
+        args_in_index = []
+        args_out_index = []
+
+        if args_in is not None:
+            args_in_index[:] = [i for (i, a) in enumerate(args_in) if type(a) == tuple]
+        if args_out is not None:
+            args_out_index[:] = [i for (i, a) in enumerate(args_out) if type(a) == tuple]
+
+        fw(".. function:: %s(bm, %s)\n\n" % (b[0], ", ".join([args_in[i][0] for i in args_in_index])))
+        
+        # -- wash the comment
+        comment_washed = []
+        for i, l in enumerate(comment):
+            assert((l.strip() == "") or
+                   (l in {"/*", " *"}) or
+                   (l.startswith(("/* ", " * "))))
+
+            l = l[3:]
+            if i == 0 and not l.strip():
+                continue
+            if l.strip():
+                l = "   " + l
+            comment_washed.append(l)
+
+        fw("\n".join(comment_washed))
+        fw("\n")
+        # -- done
+
+
+        # get the args
+        def get_args_wash(args, args_index, is_ret):
+            args_wash = []
+            for i in args_index:
+                arg = args[i]
+                if len(arg) == 3:
+                    name, tp, tp_sub = arg
+                elif len(arg) == 2:
+                    name, tp = arg
+                    tp_sub = None
+                else:
+                    print(arg)
+                    assert(0)
+
+                tp_str = ""
+
+                comment_prev = ""
+                comment_next = ""
+                if i != 0:
+                    comment_prev = args[i + 1]
+                    if type(comment_prev) == str and comment_prev.startswith("our <"):
+                        comment_prev = comment_next[5:-1]  # strip inline <...>
+                    else:
+                        comment_prev = ""
+
+                if i + 1 < len(args):
+                    comment_next = args[i + 1]
+                    if type(comment_next) == str and comment_next.startswith("inline <"):
+                        comment_next = comment_next[8:-1]  # strip inline <...>
+                    else:
+                        comment_next = ""
+                        
+                comment = ""
+                if comment_prev:
+                    comment += comment_prev.strip()
+                if comment_next:
+                    comment += ("\n" if comment_prev else "") + comment_next.strip()
+
+                if tp == BMO_OP_SLOT_FLT:
+                    tp_str = "float"
+                elif tp == BMO_OP_SLOT_INT:
+                    tp_str = "int"
+                elif tp == BMO_OP_SLOT_BOOL:
+                    tp_str = "bool"
+                elif tp == BMO_OP_SLOT_MAT:
+                    tp_str = ":class:`mathutils.Matrix`"
+                elif tp == BMO_OP_SLOT_VEC:
+                    tp_str = ":class:`mathutils.Vector`"
+                    if not is_ret:
+                        tp_str += " or any sequence of 3 floats"
+                elif tp == BMO_OP_SLOT_PTR:
+                    tp_str = "dict"
+                    assert(tp_sub is not None)
+                    if tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_BMESH:
+                        tp_str = ":class:`bmesh.types.BMesh`"
+                    elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_SCENE:
+                        tp_str = ":class:`bpy.types.Scene`"
+                    elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_OBJECT:
+                        tp_str = ":class:`bpy.types.Object`"
+                    elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_MESH:
+                        tp_str = ":class:`bpy.types.Mesh`"
+                    else:
+                        print("Cant find", vars_dict_reverse[tp_sub])
+                        assert(0)
+
+                elif tp == BMO_OP_SLOT_ELEMENT_BUF:
+                    assert(tp_sub is not None)
+                    
+                    ls = []
+                    if tp_sub & BM_VERT: ls.append(":class:`bmesh.types.BMVert`")
+                    if tp_sub & BM_EDGE: ls.append(":class:`bmesh.types.BMEdge`")
+                    if tp_sub & BM_FACE: ls.append(":class:`bmesh.types.BMFace`")
+                    assert(ls)  # must be at least one
+
+                    if tp_sub & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE:
+                        tp_str = "/".join(ls)
+                    else:
+                        tp_str = ("list of (%s)" % ", ".join(ls))
+                        
+                    del ls
+                elif tp == BMO_OP_SLOT_MAPPING:
+                    if tp_sub & BMO_OP_SLOT_SUBTYPE_MAP_EMPTY:
+                        tp_str = "set of vert/edge/face type"
+                    else:
+                        tp_str = "dict mapping vert/edge/face types to "
+                        if tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_BOOL:
+                            tp_str += "bool"
+                        elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_INT:
+                            tp_str += "int"
+                        elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_FLT:
+                            tp_str += "float"
+                        elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_ELEM:
+                            tp_str += ":class:`bmesh.types.BMVert`/:class:`bmesh.types.BMEdge`/:class:`bmesh.types.BMFace`"
+                        elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL:
+                            tp_str += "unknown internal data, not compatible with python"
+                        else:
+                            print("Cant find", vars_dict_reverse[tp_sub])
+                            assert(0)
+                else:
+                    print("Cant find", vars_dict_reverse[tp])
+                    assert(0)
+
+                args_wash.append((name, tp_str, comment))
+            return args_wash
+        # end get_args_wash
+
+        # all ops get this arg
+        fw("   :arg bm: The bmesh to operate on.\n")
+        fw("   :type bm: :class:`bmesh.types.BMesh`\n")
+
+        args_in_wash = get_args_wash(args_in, args_in_index, False)
+        args_out_wash = get_args_wash(args_out, args_out_index, True)
+
+        for (name, tp, comment) in args_in_wash:
+            if comment == "":
+                comment = "Undocumented."
+
+            fw("   :arg %s: %s\n" % (name, comment))
+            fw("   :type %s: %s\n" % (name, tp))
+        
+        if args_out_wash:
+            fw("   :return:\n\n")
+            
+            for (name, tp, comment) in args_out_wash:
+                assert(name.endswith(".out"))
+                name = name[:-4]
+                fw("      - ``%s``: %s\n\n" % (name, comment))
+                fw("        **type** %s\n" % tp)
+            
+            fw("\n")
+            fw("   :rtype: dict with string keys\n")
+
+        fw("\n\n")
+        
+    fout.close()
+    del fout
+    print(OUT_RST)
+
+
+if __name__ == "__main__":
+    main()

blender/doc/python_api/sphinx_doc_gen.py

     ./blender.bin --background --python doc/python_api/sphinx_doc_gen.py -- --output ../python_api
 
   For quick builds:
-    ./blender.bin --background --python doc/python_api/sphinx_doc_gen.py -- --partial
+    ./blender.bin --background --python doc/python_api/sphinx_doc_gen.py -- --partial bmesh.*
 
 
 Sphinx: HTML generation
         "bgl",
         "blf",
         "bmesh",
+        "bmesh.ops",
         "bmesh.types",
         "bmesh.utils",
         "bpy.app",
     __import__("aud")
 except ImportError:
     BPY_LOGGER.debug("Warning: Built without 'aud' module, docs incomplete...")
-    EXCLUDE_MODULES = EXCLUDE_MODULES + ("aud", )
+    EXCLUDE_MODULES = list(EXCLUDE_MODULES) + ["aud"]
 
 # examples
 EXAMPLES_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "examples"))
     file.close()
 
 
+def execfile(filepath):
+    global_namespace = {"__file__": filepath, "__name__": "__main__"}
+    exec(compile(open(filepath).read(), filepath, 'exec'), global_namespace)
+
+
 def write_rst_contents(basepath):
     '''
     Write the rst file of the main page, needed for sphinx (index.html)
         # misc
         "bgl", "blf", "gpu", "aud", "bpy_extras",
         # bmesh
-        "bmesh", "bmesh.types", "bmesh.utils",
+        "bmesh", "bmesh.types", "bmesh.utils", "bmesh.ops",
         )
 
     for mod in standalone_modules:
         if mod not in EXCLUDE_MODULES:
             fw("   %s\n\n" % mod)
 
+    # special case, this 'bmesh.ops.rst' is extracted from C source
+    if "bmesh.ops" not in EXCLUDE_MODULES:
+        execfile(os.path.join(SCRIPT_DIR, "rst_from_bmesh_opdefines.py"))
+
     # game engine
     if "bge" not in EXCLUDE_MODULES:
         fw(title_string("Game Engine Modules", "=", double=True))
         "bgl",  # "Blender OpenGl wrapper"
         "gpu",  # "GPU Shader Module"
 
+        "bmesh.ops",  # generated by rst_from_bmesh_opdefines.py
+
         # includes...
         "include__bmesh",
     ]

blender/extern/CMakeLists.txt

 	add_subdirectory(bullet2)
 endif()
 
-if(WITH_MOD_CLOTH_ELTOPO)
-	add_subdirectory(eltopo)
-endif()
+# now only available in a branch
+#if(WITH_MOD_CLOTH_ELTOPO)
+#	add_subdirectory(eltopo)
+#endif()
 
 if(WITH_BINRELOC)
 	add_subdirectory(binreloc)

blender/extern/SConscript

 if env['WITH_BF_GAMEENGINE']:
     SConscript(['recastnavigation/SConscript'])
 
+# now only available in a branch
+'''
 if env['WITH_BF_ELTOPO']:
     SConscript(['eltopo/SConscript'])
+'''
 
 if env['WITH_BF_BULLET']:
     SConscript(['bullet2/src/SConscript'])

blender/extern/eltopo/CMakeLists.txt

-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurai, Erwin Coumans
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
-	.
-	common
-	eltopo3d
-	common/meshes
-	common/newsparse
-	common/tunicate
-)
-
-set(INC_SYS
-
-)
-
-set(SRC
-	eltopo-capi.cpp
-	common/bfstream.cpp
-	common/ccd_wrapper.cpp
-	common/clamped_spline.cpp
-	common/collisionqueries.cpp
-	common/cubic_ccd_wrapper.cpp
-	common/fe_ccd_wrapper.cpp
-	common/fileio.cpp
-	common/levelset.cpp
-	common/makelevelset2.cpp
-	common/makelevelset3.cpp
-	common/marching_triangles.cpp
-	common/predicates.cpp
-	common/runstats.cpp
-	common/sos_ccd_wrapper.cpp
-	common/wallclocktime.cpp
-	eltopo3d/accelerationgrid.cpp
-	eltopo3d/broadphasegrid.cpp
-	eltopo3d/collisionpipeline.cpp
-	eltopo3d/dynamicsurface.cpp
-	eltopo3d/edgecollapser.cpp
-	eltopo3d/edgeflipper.cpp
-	eltopo3d/edgesplitter.cpp
-	eltopo3d/eltopo.cpp
-	eltopo3d/impactzonesolver.cpp
-	eltopo3d/meshmerger.cpp
-	eltopo3d/meshsmoother.cpp
-	eltopo3d/meshpincher.cpp
-	eltopo3d/nondestructivetrimesh.cpp
-	eltopo3d/subdivisionscheme.cpp
-	eltopo3d/surftrack.cpp
-	eltopo3d/trianglequality.cpp
-	common/newsparse/dense_matrix.cpp
-	common/newsparse/krylov_solvers.cpp
-	common/newsparse/sparse_matrix.cpp
-	common/sparse/incomplete_qr.cpp
-	common/tunicate/expansion.cpp
-	common/tunicate/intersection.cpp
-	common/tunicate/neg.cpp
-	common/tunicate/orientation.cpp
-	common/tunicate/sos_intersection.cpp
-	common/tunicate/sos_orientation.cpp
-
-	eltopo-capi.h
-	common/array1.h
-	common/array2.h
-	common/array3.h
-	common/array3_utils.h
-	common/bfstream.h
-	common/blas_wrapper.h
-	common/ccd_wrapper.h
-	common/clamped_spline.h
-	common/collisionqueries.h
-	common/fileio.h
-	common/grid3.h
-	common/hashtable.h
-	common/lapack_wrapper.h
-	common/levelset.h
-	common/makelevelset2.h
-	common/makelevelset3.h
-	common/marching_triangles.h
-	common/mat.h
-	common/matlapack.h
-	common/openglutils.h
-	common/predicates.h
-	common/util.h
-	common/vec.h
-	common/vector_math.h
-	common/wallclocktime.h
-	eltopo3d/accelerationgrid.h
-	eltopo3d/broadphase.h
-	eltopo3d/broadphasegrid.h
-	eltopo3d/dynamicsurface.h
-	eltopo3d/eltopo.h
-	eltopo3d/nondestructivetrimesh.h
-	eltopo3d/options.h
-	eltopo3d/subdivisionscheme.h
-	eltopo3d/surftrack.h
-	common/newsparse/dense_matrix.h
-	common/newsparse/krylov_solvers.h
-	common/newsparse/linear_operator.h
-	common/newsparse/sparse_matrix.h
-	common/sparse/cgsolver.h
-	common/sparse/crsolver.h
-	common/sparse/incomplete_qr.h
-	common/sparse/sparseilu.h
-	common/sparse/sparsematrix.h
-	common/sparse/sparsemilu.h
-	common/tunicate/expansion.h
-	common/tunicate/neg.h
-	common/tunicate/tunicate.h
-	)
-
-add_definitions(-DNO_GUI)
-add_definitions(-DUSE_FORTRAN_BLAS)
-
-blender_add_lib(extern_eltopo "${SRC}" "${INC}" "${INC_SYS}")

blender/extern/eltopo/SConscript

-#!/usr/bin/python
-
-Import('env')
-
-import os
-
-defs = []
-
-
-eltopo_src = env.Glob("common/*.cpp") + env.Glob("eltopo3d/*.cpp") + env.Glob("common/newsparse/*.cpp") + env.Glob("common/tunicate/*.cpp") + env.Glob("common/sparse/*.cpp") + ["eltopo-capi.cpp"]
-eltopo_src.remove( "common" + os.sep + "gluvi.cpp" )
-eltopo_src.remove( "common" + os.sep + "openglutils.cpp" )
-
-defs.append('USE_FORTRAN_BLAS')
-defs.append('NO_GUI')
-
-incs = '. common eltopo3d common/newsparse common/meshes common/sparse common/tunicate'
-
-env.BlenderLib ('extern_eltopo3d', Split(eltopo_src), Split(incs), defs, libtype=['extern'], priority=[40] )
-

blender/extern/eltopo/common/array1.h

-#ifndef ARRAY1_H
-#define ARRAY1_H
-
-#include <algorithm>
-#include <cassert>
-#include <climits>
-#include <cstdlib>
-#include <cstring>
-#include <iostream>
-#include <stdexcept>
-#include <vector>
-
-#if defined(_WIN32) && !defined(FREE_WINDOWS)
-#include "BaseTsd.h"
-typedef SSIZE_T ssize_t;
-#endif
-
-// In this file:
-//   Array1<T>: a dynamic 1D array for plain-old-data (not objects)
-//   WrapArray1<T>: a 1D array wrapper around an existing array (perhaps objects, perhaps data)
-// For the most part std::vector operations are supported, though for the Wrap version
-// note that memory is never allocated/deleted and constructor/destructors are never called
-// from within the class, thus only shallow copies can be made and some operations such as
-// resize() and push_back() are limited.
-// Note: for the most part assertions are done with assert(), not exceptions...
-
-// gross template hacking to determine if a type is integral or not
-struct Array1True {};
-struct Array1False {};
-template<typename T> struct Array1IsIntegral{ typedef Array1False type; }; // default: no (specializations to yes follow)
-template<> struct Array1IsIntegral<bool>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<char>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<signed char>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<unsigned char>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<short>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<unsigned short>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<int>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<unsigned int>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<long>{ typedef Array1True type; };
-template<> struct Array1IsIntegral<unsigned long>{ typedef Array1True type; };
-//template<> struct Array1IsIntegral<long long>{ typedef Array1True type; };
-//template<> struct Array1IsIntegral<unsigned long long>{ typedef Array1True type; };
-
-//============================================================================
-template<typename T>
-struct Array1
-{
-    // STL-friendly typedefs
-    
-    typedef T* iterator;
-    typedef const T* const_iterator;
-    typedef unsigned long size_type;
-    typedef long difference_type;
-    typedef T& reference;
-    typedef const T& const_reference;
-    typedef T value_type;
-    typedef T* pointer;
-    typedef const T* const_pointer;
-    typedef std::reverse_iterator<iterator> reverse_iterator;
-    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-    
-    // the actual representation
-    
-    unsigned long n;
-    unsigned long max_n;
-    T* data;
-    
-    // STL vector's interface, with additions, but only valid when used with plain-old-data
-    
-    Array1(void)
-    : n(0), max_n(0), data(0)
-    {}
-    
-    // note: default initial values are zero
-    Array1(unsigned long n_)
-    : n(0), max_n(0), data(0)
-    {
-        if(n_>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-        data=(T*)std::calloc(n_, sizeof(T));
-        if(!data) throw std::bad_alloc();
-        n=n_;
-        max_n=n_;
-    }
-    
-    Array1(unsigned long n_, const T& value)
-    : n(0), max_n(0), data(0)
-    {
-        if(n_>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-        data=(T*)std::calloc(n_, sizeof(T));
-        if(!data) throw std::bad_alloc();
-        n=n_;
-        max_n=n_;
-        for(unsigned long i=0; i<n; ++i) data[i]=value;
-    }
-    
-    Array1(unsigned long n_, const T& value, unsigned long max_n_)
-    : n(0), max_n(0), data(0)
-    {
-        assert(n_<=max_n_);
-        if(max_n_>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-        data=(T*)std::calloc(max_n_, sizeof(T));
-        if(!data) throw std::bad_alloc();
-        n=n_;
-        max_n=max_n_;
-        for(unsigned long i=0; i<n; ++i) data[i]=value;
-    }
-    
-    Array1(unsigned long n_, const T* data_)
-    : n(0), max_n(0), data(0)
-    {
-        if(n_>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-        data=(T*)std::calloc(n_, sizeof(T));
-        if(!data) throw std::bad_alloc();
-        n=n_;
-        max_n=n_;
-        assert(data_);
-        std::memcpy(data, data_, n*sizeof(T));
-    }
-    
-    Array1(unsigned long n_, const T* data_, unsigned long max_n_)
-    : n(0), max_n(0), data(0)
-    {
-        assert(n_<=max_n_);
-        if(max_n_>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-        data=(T*)std::calloc(max_n_, sizeof(T));
-        if(!data) throw std::bad_alloc();
-        max_n=max_n_;
-        n=n_;
-        assert(data_);
-        std::memcpy(data, data_, n*sizeof(T));
-    }
-    
-    Array1(const Array1<T> &x)
-    : n(0), max_n(0), data(0)
-    {
-        data=(T*)std::malloc(x.n*sizeof(T));
-        if(!data) throw std::bad_alloc();
-        n=x.n;
-        max_n=x.n;
-        std::memcpy(data, x.data, n*sizeof(T));
-    }
-    
-    ~Array1(void)
-    {
-        std::free(data);
-#ifndef NDEBUG
-        data=0;
-        n=max_n=0;
-#endif
-    }
-    
-    const T& operator[](unsigned long i) const
-    { return data[i]; }
-    
-    T& operator[](unsigned long i)
-    { return data[i]; }
-    
-    // these are range-checked (in debug mode) versions of operator[], like at()
-    const T& operator()(unsigned long i) const
-    {
-        assert(i<n);
-        return data[i];
-    }
-    
-    T& operator()(unsigned long i)
-    {
-        assert(i<n);
-        return data[i];
-    }
-    
-    Array1<T>& operator=(const Array1<T>& x)
-    {
-        if(max_n<x.n){
-            T* new_data=(T*)std::malloc(x.n*sizeof(T));
-            if(!new_data) throw std::bad_alloc();
-            std::free(data);
-            data=new_data;
-            max_n=x.n;
-        }
-        n=x.n;
-        std::memcpy(data, x.data, n*sizeof(T));
-        return *this;
-    }
-    
-    bool operator==(const Array1<T>& x) const
-    {
-        if(n!=x.n) return false;
-        for(unsigned long i=0; i<n; ++i) if(!(data[i]==x.data[i])) return false;
-        return true;
-    }
-    
-    bool operator!=(const Array1<T>& x) const
-    {
-        if(n!=x.n) return true;
-        for(unsigned long i=0; i<n; ++i) if(data[i]!=x.data[i]) return true;
-        return false;
-    }
-    
-    bool operator<(const Array1<T>& x) const
-    {
-        for(unsigned long i=0; i<n && i<x.n; ++i){
-            if(data[i]<x[i]) return true;
-            else if(x[i]<data[i]) return false;
-        }
-        return n<x.n;
-    }
-    
-    bool operator>(const Array1<T>& x) const
-    {
-        for(unsigned long i=0; i<n && i<x.n; ++i){
-            if(data[i]>x[i]) return true;
-            else if(x[i]>data[i]) return false;
-        }
-        return n>x.n;
-    }
-    
-    bool operator<=(const Array1<T>& x) const
-    {
-        for(unsigned long i=0; i<n && i<x.n; ++i){
-            if(data[i]<x[i]) return true;
-            else if(x[i]<data[i]) return false;
-        }
-        return n<=x.n;
-    }
-    
-    bool operator>=(const Array1<T>& x) const
-    {
-        for(unsigned long i=0; i<n && i<x.n; ++i){
-            if(data[i]>x[i]) return true;
-            else if(x[i]>data[i]) return false;
-        }
-        return n>=x.n;
-    }
-    
-    void add_unique(const T& value)
-    {
-        for(unsigned long i=0; i<n; ++i) if(data[i]==value) return;
-        if(n==max_n) grow();
-        data[n++]=value;
-    }
-    
-    void assign(const T& value)
-    { for(unsigned long i=0; i<n; ++i) data[i]=value; }
-    
-    void assign(unsigned long num, const T& value)
-    { fill(num, value); } 
-    
-    // note: copydata may not alias this array's data, and this should not be
-    // used when T is a full object (which defines its own copying operation)
-    void assign(unsigned long num, const T* copydata)
-    {
-        assert(num==0 || copydata);
-        if(num>max_n){
-            if(num>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-            std::free(data);
-            data=(T*)std::malloc(num*sizeof(T));
-            if(!data) throw std::bad_alloc();
-            max_n=num;
-        }
-        n=num;
-        std::memcpy(data, copydata, n*sizeof(T));
-    }
-    
-    template<typename InputIterator>
-    void assign(InputIterator first, InputIterator last)
-    { assign_(first, last, typename Array1IsIntegral<InputIterator>::type()); }
-    
-    template<typename InputIterator>
-    void assign_(InputIterator first, InputIterator last, Array1True )
-    { fill(first, last); }
-    
-    template<typename InputIterator>
-    void assign_(InputIterator first, InputIterator last, Array1False )
-    {
-        unsigned long i=0;
-        InputIterator p=first;
-        for(; p!=last; ++p, ++i){
-            if(i==max_n) grow();
-            data[i]=*p;
-        }
-        n=i;
-    }
-    
-    const T& at(unsigned long i) const
-    {
-        assert(i<n);
-        return data[i];
-    }
-    
-    T& at(unsigned long i)
-    {
-        assert(i<n);
-        return data[i];
-    }
-    
-    const T& back(void) const
-    { 
-        assert(data && n>0);
-        return data[n-1];
-    }
-    
-    T& back(void)
-    {
-        assert(data && n>0);
-        return data[n-1];
-    }
-    
-    const T* begin(void) const
-    { return data; }
-    
-    T* begin(void)
-    { return data; }
-    
-    unsigned long capacity(void) const
-    { return max_n; }
-    
-    void clear(void)
-    {
-        std::free(data);
-        data=0;
-        max_n=0;
-        n=0;
-    }
-    
-    bool empty(void) const
-    { return n==0; }
-    
-    const T* end(void) const
-    { return data+n; }
-    
-    T* end(void)
-    { return data+n; }
-    
-    void erase(unsigned long index)
-    {
-        assert(index<n);
-        for(unsigned long i=index; i<n-1; ++i)
-            data[i]=data[i-1];
-        pop_back();
-    }
-    
-    void fill(unsigned long num, const T& value)
-    {
-        if(num>max_n){
-            if(num>ULONG_MAX/sizeof(T)) throw std::bad_alloc();
-            std::free(data);
-            data=(T*)std::malloc(num*sizeof(T));
-            if(!data) throw std::bad_alloc();
-            max_n=num;
-        }
-        n=num;
-        for(unsigned long i=0; i<n; ++i) data[i]=value;
-    }
-    
-    const T& front(void) const
-    {
-        assert(n>0);
-        return *data;
-    }
-    
-    T& front(void)
-    {
-        assert(n>0);
-        return *data;
-    }
-    
-    void grow(void)
-    {
-        unsigned long new_size=(max_n*sizeof(T)<ULONG_MAX/2 ? 2*max_n+1 : ULONG_MAX/sizeof(T));
-        T *new_data=(T*)std::realloc(data, new_size*sizeof(T));
-        if(!new_data) throw std::bad_alloc();
-        data=new_data;