Exemplo n.º 1
0
def modify_file(filename, classname, line, orig):
    if (SIXMOZ_options.path not in filename or filename not in SIXMOZ_files.get_files()):
        return
    if orig.find(SIXMOZ_rules.get_conf('to_add')) != -1 or orig.find(SIXMOZ_rules.get_conf('to_find')) != -1:
        SIXMOZ_stats.overrided.append(classname + "::" + orig)
        return
    liste = open(filename, "r").readlines()
    i = 0
    content = ""
    modified = 0
    while i < len(liste):
        mod =  ""
        mod = liste[i]
        if ((i + 1) == line):
            SIXMOZ_logger.print_debug("Before: [" + str(line) + "] " + str(liste[i]))
            if (liste[i].find(SIXMOZ_rules.get_conf('to_add')) == -1):
                i, mod, content, found = find_meth(liste, i, content)
                if (found == 1):
                    SIXMOZ_stats.overrided.append(classname + "::" + orig)
                    SIXMOZ_stats.real_overrided.append(classname + "::" + orig)
                    modified = 1
                    if (filename not in SIXMOZ_stats.mod_files):
                        SIXMOZ_stats.mod_files.append(filename)
            else:
                content += mod
                i += 1
        elif (len(mod) > 0):
            content += mod
            i += 1
        else:
            content += liste[i]
            i += 1
    if (modified == 1):
        SIXMOZ_logger.dryrun(filename, content)
Exemplo n.º 2
0
def over_meth(meth):
    meth = meth.replace("NS_IMETHOD_ ", "")
    meth = meth.replace("NS_IMETHOD ", "")
    meth = meth.replace("virtual ", "")
    meth = meth.replace(SIXMOZ_rules.get_conf('to_add'), "")
    meth = meth.replace(SIXMOZ_rules.get_conf('to_find'), "")
    meth = meth.replace("  ", " ")
    return (meth)
Exemplo n.º 3
0
 def __init__(self):
     #Number of MOZ_OVERRIDE before launch
     self.begin = subprocess.check_output(
         "find " + SIXMOZ_options.path + " -type f -readable " +
         SIXMOZ_rules.get_conf('extensions') +
         " -or -name \"*.cpp\" | xargs grep " +
         SIXMOZ_rules.get_conf('to_add') + " | wc -l",
         shell=True).decode()
Exemplo n.º 4
0
def _help():
    print("Usage: ./this_script Path [-v|-d] [--dryrun] [-h|--help] [-W]")
    print("-v:\t\tVerbose")
    print("-d:\t\tDebug (Include Verbose)")
    print("--dryrun:\tPerforms a Dryrun (no changes)")
    print("-W:\t\tAdd %s to all NS_IMETHOD (won't compile)"% SIXMOZ_rules.get_conf('to_add'))
    print("-I folder:\tFolder you want to get headers generated from idl_files")
    print("-h --help:\tPrint this Menu")
    print("Path:\t\tFolder you want to add %s"% SIXMOZ_rules.get_conf('to_add'))
Exemplo n.º 5
0
def _help():
    print("Usage: ./this_script Path [-v|-d] [--dryrun] [-h|--help] [-W]")
    print("-v:\t\tVerbose")
    print("-d:\t\tDebug (Include Verbose)")
    print("--dryrun:\tPerforms a Dryrun (no changes)")
    print("-W:\t\tAdd %s to all NS_IMETHOD (won't compile)" %
          SIXMOZ_rules.get_conf('to_add'))
    print(
        "-I folder:\tFolder you want to get headers generated from idl_files")
    print("-h --help:\tPrint this Menu")
    print("Path:\t\tFolder you want to add %s" %
          SIXMOZ_rules.get_conf('to_add'))
Exemplo n.º 6
0
 def add_moz_override(self):
     SIXMOZ_logger.print_info("Stage 5/6: Adding " + SIXMOZ_rules.get_conf('to_add') + " to files")
     for cppclass in self.classes:
         for classOmeths in cppclass.Omeths:
             modify_file(cppclass.filename, cppclass.name, classOmeths[3], classOmeths[2])
         for classOfuncs in cppclass.Ofuncs:
             modify_file(cppclass.filename, cppclass.name, classOfuncs[3], classOfuncs[2])
Exemplo n.º 7
0
    def display(self, classes, files, idl_files):
        virt_missed = 0
        meth_missed = 0
        firstprint = 0

        SIXMOZ_logger.print_verbose("")
        SIXMOZ_logger.print_verbose("Statistics")
        for cppclass in classes:
            for classOmeths in cppclass.Omeths:
                tmp = cppclass.name + "::" + classOmeths[2]
                if tmp not in self.overrided:
                    if firstprint == 0:
                        firstprint = 1
                        SIXMOZ_logger.print_verbose("NOT OVERRIDED!!!:")
                    virt_missed += 1
                    SIXMOZ_logger.print_verbose(cppclass.filename + "\t" \
                                  + "M " + tmp + "\t%d" % classOmeths[3])
            for classOfuncs in cppclass.Ofuncs:
                tmp = cppclass.name + "::" + classOfuncs[2]
                if tmp not in self.overrided:
                    if firstprint == 0:
                        firstprint = 1
                        SIXMOZ_logger.print_verbose("NOT OVERRIDED!!!:")
                    meth_missed += 1
                    SIXMOZ_logger.print_verbose(cppclass.filename + "\t" \
                                  + "F " + tmp + "\t%d" % classOfuncs[3])

        self.display_base(classes, files, idl_files)
        SIXMOZ_logger.print_verbose("Methods " +
                                    SIXMOZ_rules.get_conf('to_add') +
                                    " @Begin: " + self.begin)
        SIXMOZ_logger.print_info("Overrided %d methods" %
                                 len(set(self.real_overrided)))
        SIXMOZ_logger.print_verbose("Final Modified Meths: %d" %
                                    self.modified_meths)
        SIXMOZ_logger.print_verbose("Still Missing %d methods" % virt_missed)
        SIXMOZ_logger.print_verbose("Still Missing %d member functions" %
                                    meth_missed)
        output = subprocess.check_output(
            "find " + SIXMOZ_options.path + " -type f -readable " +
            SIXMOZ_rules.get_conf('extensions') +
            " -or -name \"*.cpp\" | xargs grep " +
            SIXMOZ_rules.get_conf('to_add') + " | wc -l",
            shell=True).decode()
        SIXMOZ_logger.print_info(
            SIXMOZ_rules.get_conf('to_add') + " Methods in Code: " + output)
Exemplo n.º 8
0
 def __find_files():
     SIXMOZ_logger.print_info("Stage 1/6: Getting files to parse: %s" %
                              SIXMOZ_options.path)
     files = subprocess.check_output("find " + SIXMOZ_options.path +
                                     " -type f -readable " +
                                     SIXMOZ_rules.get_conf('extensions') +
                                     " -or -name \"*.cpp\" | sort",
                                     shell=True).decode().split("\n")
     return (files)
Exemplo n.º 9
0
 def add_moz_override(self):
     SIXMOZ_logger.print_info("Stage 5/6: Adding " +
                              SIXMOZ_rules.get_conf('to_add') + " to files")
     for cppclass in self.classes:
         for classOmeths in cppclass.Omeths:
             modify_file(cppclass.filename, cppclass.name, classOmeths[3],
                         classOmeths[2])
         for classOfuncs in cppclass.Ofuncs:
             modify_file(cppclass.filename, cppclass.name, classOfuncs[3],
                         classOfuncs[2])
Exemplo n.º 10
0
    def display(self, classes, files, idl_files):
        virt_missed = 0
        meth_missed = 0
        firstprint = 0

        SIXMOZ_logger.print_verbose("")
        SIXMOZ_logger.print_verbose("Statistics")
        for cppclass in classes:
            for classOmeths  in cppclass.Omeths:
                tmp = cppclass.name + "::" +  classOmeths[2]
                if tmp not in self.overrided:
                    if firstprint == 0:
                        firstprint = 1
                        SIXMOZ_logger.print_verbose("NOT OVERRIDED!!!:")
                    virt_missed += 1
                    SIXMOZ_logger.print_verbose(cppclass.filename + "\t" \
                                  + "M " + tmp + "\t%d" % classOmeths[3])
            for classOfuncs in cppclass.Ofuncs:
                tmp = cppclass.name + "::" + classOfuncs[2]
                if tmp not in self.overrided:
                    if firstprint == 0:
                        firstprint = 1
                        SIXMOZ_logger.print_verbose("NOT OVERRIDED!!!:")
                    meth_missed += 1
                    SIXMOZ_logger.print_verbose(cppclass.filename + "\t" \
                                  + "F " + tmp + "\t%d" % classOfuncs[3])

        self.display_base(classes, files, idl_files)
        SIXMOZ_logger.print_verbose("Methods " + SIXMOZ_rules.get_conf('to_add') + " @Begin: " + self.begin)
        SIXMOZ_logger.print_info("Overrided %d methods" % len(set(self.real_overrided)))
        SIXMOZ_logger.print_verbose("Final Modified Meths: %d" % self.modified_meths)
        SIXMOZ_logger.print_verbose("Still Missing %d methods" % virt_missed)
        SIXMOZ_logger.print_verbose("Still Missing %d member functions" % meth_missed)
        output = subprocess.check_output("find " + SIXMOZ_options.path + " -type f -readable " +
                                         SIXMOZ_rules.get_conf('extensions') +
                                         " -or -name \"*.cpp\" | xargs grep " +
                                         SIXMOZ_rules.get_conf('to_add') + " | wc -l", shell=True).decode()
        SIXMOZ_logger.print_info(SIXMOZ_rules.get_conf('to_add') + " Methods in Code: " + output)
Exemplo n.º 11
0
def add_it(line, it):    
    SIXMOZ_logger.print_debug("Error: " + line)
    added = 0
    l = get_good_pos(line, it)
    mod = line[:l]
    if ((len(line[:l]) - 1) >= 0 and line[:l][len(line[:l]) - 1] != ' '):
        mod += " "
    mod += SIXMOZ_rules.get_conf('to_add')
    if (len(line[l:]) > 0 and line[l:][0] != ';' and line[l:][0] != ' ' and line[l:][0] != '\n'):
        mod += " "
    mod += line[l:]
    SIXMOZ_stats.modified_meths += 1
    added = 1
    return (mod, added)
Exemplo n.º 12
0
def modify_file(filename, classname, line, orig):
    if (SIXMOZ_options.path not in filename
            or filename not in SIXMOZ_files.get_files()):
        return
    if orig.find(SIXMOZ_rules.get_conf('to_add')) != -1 or orig.find(
            SIXMOZ_rules.get_conf('to_find')) != -1:
        SIXMOZ_stats.overrided.append(classname + "::" + orig)
        return
    liste = open(filename, "r").readlines()
    i = 0
    content = ""
    modified = 0
    while i < len(liste):
        mod = ""
        mod = liste[i]
        if ((i + 1) == line):
            SIXMOZ_logger.print_debug("Before: [" + str(line) + "] " +
                                      str(liste[i]))
            if (liste[i].find(SIXMOZ_rules.get_conf('to_add')) == -1):
                i, mod, content, found = find_meth(liste, i, content)
                if (found == 1):
                    SIXMOZ_stats.overrided.append(classname + "::" + orig)
                    SIXMOZ_stats.real_overrided.append(classname + "::" + orig)
                    modified = 1
                    if (filename not in SIXMOZ_stats.mod_files):
                        SIXMOZ_stats.mod_files.append(filename)
            else:
                content += mod
                i += 1
        elif (len(mod) > 0):
            content += mod
            i += 1
        else:
            content += liste[i]
            i += 1
    if (modified == 1):
        SIXMOZ_logger.dryrun(filename, content)
Exemplo n.º 13
0
def add_it(line, it):
    SIXMOZ_logger.print_debug("Error: " + line)
    added = 0
    l = get_good_pos(line, it)
    mod = line[:l]
    if ((len(line[:l]) - 1) >= 0 and line[:l][len(line[:l]) - 1] != ' '):
        mod += " "
    mod += SIXMOZ_rules.get_conf('to_add')
    if (len(line[l:]) > 0 and line[l:][0] != ';' and line[l:][0] != ' '
            and line[l:][0] != '\n'):
        mod += " "
    mod += line[l:]
    SIXMOZ_stats.modified_meths += 1
    added = 1
    return (mod, added)
Exemplo n.º 14
0
 def __find_idl_files():
     idl_files = []
     if (SIXMOZ_options.idl_folder != ""):
         if (not os.path.exists(SIXMOZ_options.idl_folder)):
             print("Options -I %s doesn't not exist" %
                   SIXMOZ_options.idl_folder)
             sys.exit(1)
         SIXMOZ_logger.print_info("Getting Files from idl_folder: " +
                                  SIXMOZ_options.idl_folder)
         idl_files = subprocess.check_output(
             "find " + SIXMOZ_options.idl_folder +
             " -type f -readable \( " +
             SIXMOZ_rules.get_conf('extensions') +
             " \) -and -not -path \"" + SIXMOZ_options.path + "*\" | sort",
             shell=True).decode().split("\n")
     return (idl_files)
Exemplo n.º 15
0
def find_meth(liste, i, content):
    ok = 1
    found = 0
    while (ok == 1):
        mod = ""
        while (i < len(liste) and mod.find(';') == -1 and mod.find('{') == -1):
            mod += liste[i]
            i += 1
        if (mod.find(';') != -1 or mod.find('{') != -1):
            if (mod.find(SIXMOZ_rules.get_conf('to_add')) == -1):
                mod, found = add_it(mod, 0)
            ok = 0
            content += mod
            mod = ""
        else:
            content += mod
        if (i >= len(liste)):
            ok = 0
    return (i, mod, str(content), found)
Exemplo n.º 16
0
def find_meth(liste, i, content):
    ok = 1
    found = 0
    while (ok == 1):
        mod = ""
        while (i < len(liste) and mod.find(';') == -1 and mod.find('{') == -1):
            mod += liste[i]
            i += 1
        if (mod.find(';') != -1 or mod.find('{') != -1):
            if (mod.find(SIXMOZ_rules.get_conf('to_add')) == -1):
                mod, found = add_it(mod, 0)
            ok = 0
            content += mod
            mod = ""
        else:
            content += mod
        if (i >= len(liste)):
            ok = 0
    return (i, mod, str(content), found)
Exemplo n.º 17
0
#!/usr/bin/python

import sys

sys.path[0] += "/modules"

from rules import SIXMOZ_rules

SIXMOZ_rules.init()

from override import SIXMOZ_override

Six = SIXMOZ_override()
Six.run()
Exemplo n.º 18
0
 def __init__(self):
     #Number of MOZ_OVERRIDE before launch
     self.begin = subprocess.check_output("find " + SIXMOZ_options.path + " -type f -readable " +
                                          SIXMOZ_rules.get_conf('extensions') + " -or -name \"*.cpp\" | xargs grep " +
                                          SIXMOZ_rules.get_conf('to_add') + " | wc -l", shell=True).decode()