Beispiel #1
0
def get_klasses(infilter=None):
    klasses = {}

    et_classes = ET.ElementTree()
    et_classes.parse(filepath + methodfile)

    classes = et_classes.getiterator("apiClassifier")
    for c in classes:
        classname = c.find('apiName').text
        #print classname
        if infilter is not None: #filtering in use
            if classname not in infilter:
                print "Filtering out class:", classname
                continue
        k = Klass(classname)
        klasses[classname] = k

        classdetail = c.find('apiClassifierDetail')
        classdef = classdetail.find('apiClassifierDef')
        baseclass = classdef.find('apiBaseClassifier')
        if baseclass is not None:
            supername = baseclass.text
            if supername != 'Object':
                k.supers.append(baseclass.text)

        operations = c.getiterator("apiOperation")
        for op in operations:
            opname = op.find('apiName').text
            #print opname
            m = Method(opname)
            k.methods[opname] = m

            details = op.getiterator("apiOperationDetail")
            for det in details:
                opdef = det.find('apiOperationDef')
                params = opdef.getiterator('apiParam')
                for par in params:
                    parname = par.find('apiItemName').text
                    m.params.append(parname)

    return klasses
Beispiel #2
0
 def klass(self, klass):
     self.__klass = Klass(klass)
     self.__klass(self)
Beispiel #3
0
def get_classes(infilter=None):
    klasses = dict()
    k = Klass('PongRoomModule')
    k.supers = ['Module', 'Runnable']
    k.methods['run'] = Method('run')
    k.methods['update']  =Method('update', ['tick'])
    k.methods['onAddClient'] = Method('onAddClient', ['evt'])
    k.methods['onRemoveClient'] = Method('onRemoveClient', ['evt'])
    k.methods['onClientAttributeChanged'] = Method('onClientAttributeChanged', ['evt'])
    k.methods['shutdown'] = Method('shutdown')
    k.methods['updatePaddle'] = Method('updatePaddle', ['paddle', 'tick'])
    k.methods['updateBall'] = Method('updateBall', ['tick'])
    k.methods['bounceBall'] = Method('bounceBall', ['tick'])
    k.methods['resetBall'] = Method('resetBall')
    k.methods['sendScodeUpdate'] = Method('sendScoreUpdate')

    k.fields = ['m_ctx', 'm_thread', 'm_leftPlayer', 'm_rightPlayer', 'm_leftPaddle', 'm_rightPaddle', 'm_leftPlayerScore', 'm_rightPlayerScore', 'm_ball', 'm_isGameRunning', 'GAME_UPDATE_INTERVAL', 'BALL_UPDATE_INTERVAL', 'COURT_HEIGHT', 'COURT_WIDTH', 'BALL_SIZE', 'INITIAL_BALL_SPEED', 'BALL_SPEEDUP', 'PADDLE_HEIGHT', 'PADDLE_WIDTH', 'PADDLE_SPEED', 'WALL_HEIGHT', 'ATTR_PADDLE', 'ATTR_SIDE', 'ATTR_STATUS', 'm_decFmt']

    k.relations = list(set(['ModuleContext', 'Client', 'PongObject']))

    klasses['PongRoomModule'] = k

    l = Klass('PongObject')
    l.methods['setX'] = Method('setX', ['x'])
    l.methods['getX'] = Method('getX')
    l.methods['setY'] = Method('setY', ['y'])
    l.methods['getY'] = Method('getY')
    l.methods['getDirection'] = Method('getDirection')
    l.methods['setDirection'] = Method('setDirection', ['direction'])
    l.methods['setSpeed'] = Method('setSpeed', ['speed'])
    l.methods['getSpeed'] = Method('getSpeed')

    l.fields = ['m_x', 'm_y', 'm_speed', 'm_direction']

    klasses['PongObject'] = l

    return klasses
Beispiel #4
0
    
    klasses = []
    filenames = [f for f in listdir('.') if filepat.match(f)]

    for filename in filenames:
        f = [file for file in open(filename)]
        classes = [classpat.match(line) for line in f if classpat.match(line)]
        operations = [operpat.match(line) for line in f if operpat.match(line)]
        attributes = [attrpat.match(line) for line in f if attrpat.match(line)]
        if len(classes) > 1:
            print 'This script only supports one class per file.'
            print 'File %s contains more than one class.' % filename
            print len(classes)
        name, parents = classes[0].groups()
        parents = parents.strip()
        temp = Klass(name)
        for parent in parents.split(', '):
            parent = parent.strip().split(' ')[-1]
            temp.add_parent(parent)
        for match in operations:
                g = match.groups()
                temp.add_operation(g[1], g[2], g[3])
        for match in attributes:
                g = match.groups()
                temp.add_attribute(g[0], g[1])
        klasses.append(temp)
                
    prepstring = 'digraph %s {\n\tfontsize = %s\n\trankdir = BT\n\t%s\n\n\t' % (graphname, fontsize, printfriendly) +\
                 'node [\n\t\tfontsize = %s\n\t\tshape = "record"\n\t]\n\n\t' % fontsize +\
                 'edge [\n\t\tpenwidth = %s\n\t\tarrowhead = "empty"\n\t]\n\n' % penwidth
    endstring = '}'
Beispiel #5
0
    klasses = []
    filenames = [f for f in listdir('.') if filepat.match(f)]

    for filename in filenames:
        f = [file for file in open(filename)]
        classes = [classpat.match(line) for line in f if classpat.match(line)]
        operations = [operpat.match(line) for line in f if operpat.match(line)]
        attributes = [attrpat.match(line) for line in f if attrpat.match(line)]
        if len(classes) > 1:
            print 'This script only supports one class per file.'
            print 'File %s contains more than one class.' % filename
            print len(classes)
        name, parents = classes[0].groups()
        parents = parents.strip()
        temp = Klass(name)
        for parent in parents.split(', '):
            parent = parent.strip().split(' ')[-1]
            temp.add_parent(parent)
        for match in operations:
            g = match.groups()
            temp.add_operation(g[1], g[2], g[3])
        for match in attributes:
            g = match.groups()
            temp.add_attribute(g[0], g[1])
        klasses.append(temp)

    prepstring = 'digraph %s {\n\tfontsize = %s\n\trankdir = BT\n\t%s\n\n\t' % (graphname, fontsize, printfriendly) +\
                 'node [\n\t\tfontsize = %s\n\t\tshape = "record"\n\t]\n\n\t' % fontsize +\
                 'edge [\n\t\tpenwidth = %s\n\t\tarrowhead = "empty"\n\t]\n\n' % penwidth
    endstring = '}'