gecko-dev/memory/mozalloc
Ehsan Akhgari 2824b29025 Bug 895322 - Part 1: Replace the usages of MOZ_STATIC_ASSERT with C++11 static_assert; r=Waldo
This patch was mostly generated by running the following scripts on the codebase, with some
manual changes made afterwards:

# static_assert.sh
#!/bin/bash
# Command to convert an NSPR integer type to the equivalent standard integer type

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.cc" \
         -o -iname "*.mm" \) | \
    xargs -n 1 `dirname $0`/assert_replacer.py #sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_STATIC_ASSERT static_assert
hg rev --no-backup mfbt/Assertions.h \
                   media/webrtc/signaling/src/sipcc/core/includes/ccapi.h \
                   modules/libmar/src/mar_private.h \
                   modules/libmar/src/mar.h


# assert_replacer.py
#!/usr/bin/python

import sys
import re

pattern = re.compile(r"\bMOZ_STATIC_ASSERT\b")

def replaceInPlace(fname):
  print fname
  f = open(fname, "rw+")
  lines = f.readlines()
  for i in range(0, len(lines)):
    while True:
      index = re.search(pattern, lines[i])
      if index != None:
        index = index.start()
        lines[i] = lines[i][0:index] + "static_assert" + lines[i][index+len("MOZ_STATIC_ASSERT"):]
        for j in range(i + 1, len(lines)):
          if lines[j].find("                 ", index) == index:
            lines[j] = lines[j][0:index] + lines[j][index+4:]
          else:
            break
      else:
        break
  f.seek(0, 0)
  f.truncate()
  f.write("".join(lines))
  f.close()

argc = len(sys.argv)
for i in range(1, argc):
  replaceInPlace(sys.argv[i])

--HG--
extra : rebase_source : 4b4a4047d82f2c205b9fad8d56dfc3f1afc0b045
2013-07-18 13:59:53 -04:00
..
Makefile.in Bug 889787 - Define XP_LINUX globally; r=ted 2013-07-16 17:10:10 -04:00
fallible.h Bug 737164 prerequisite - move mozilla::fallible_t to its own header so that everyone can reference it reasonable, r=cjones 2012-05-08 12:30:37 -04:00
moz.build Bug 875934 - Move LIBRARY_NAME to moz.build (batch #1); r=mshal 2013-06-17 15:21:01 -04:00
mozalloc.cpp bug 822717 - remove checks for old gcc r=glandium 2012-12-18 13:22:28 -05:00
mozalloc.h Bug 863116 - MOZ_ALWAYS_INLINE should not inline in debug builds (r=Waldo) 2013-04-19 10:55:34 -07:00
mozalloc_abort.cpp Bug 824224: Make mozalloc_abort() not MOZ_NORETURN and log errors to logcat. r=glandium 2013-01-04 13:28:37 -08:00
mozalloc_abort.h Bug 829327: Mark mozalloc_abort() as MOZ_NORETURN (except on ARM, where we're pretty sure it breaks crash stacks). r=cjones 2013-01-11 09:29:02 -08:00
mozalloc_macro_wrappers.h Bug 581478: undef strdup before (re)defining it in mozalloc_macro_wrappers.h. r=glandium 2013-07-25 18:14:41 -07:00
mozalloc_oom.cpp Bug 895322 - Part 1: Replace the usages of MOZ_STATIC_ASSERT with C++11 static_assert; r=Waldo 2013-07-18 13:59:53 -04:00
mozalloc_oom.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
mozalloc_undef_macro_wrappers.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
msvc_raise_wrappers.cpp Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
msvc_raise_wrappers.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
msvc_throw_wrapper.cpp Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
msvc_throw_wrapper.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
throw_gcc.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
throw_msvc.h Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00