Commit Graph

6 Commits

Author SHA1 Message Date
Ehsan Akhgari
085494b95d 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
Jeff Walden
0249601aea Bug 798179 - Implement mozilla::MakeUnsigned. r=froydnj
--HG--
extra : rebase_source : fdd1fe8841d1bc42c1758cd4d477969b3f382b30
2013-03-05 15:44:02 -08:00
Jeff Walden
18109e4f0c Bug 798179 - Implement mozilla::MakeSigned. r=froydnj
--HG--
extra : rebase_source : 357bf046219e37959d66fde6b2ad2b7f5746960f
2013-03-05 15:44:02 -08:00
Jeff Walden
d680c05974 Bug 873585 - Silence a vacuous-comparison-against-0 warning when compiling with gcc 4.5, at least. Also make IsSigned/IsUnsigned actually work on floating-point types. r=froydnj
--HG--
extra : rebase_source : 149695699ddb5cde3058a066785c2dc4c7c221e7
2013-05-17 11:07:02 -07:00
Ehsan Akhgari
0f4db0eb2e Bug 802806 - Make mfbt's IsBaseOf work with multiple inheritance; r=Waldo 2012-10-17 17:37:53 -04:00
Jeff Walden
1128bafac5 Bug 766347 - Implement mozilla::IsConvertible to detect when a value of one type will convert to a value of another type. r=luke
--HG--
extra : rebase_source : d25c1b84dfc928a0bc4dcfb43e31b6035882849e
2012-06-19 13:55:23 -07:00