示例#1
0
def domainInterface2dict(semObj):
    out = a3t.gen2dict(semObj)

    da = a3t.inTwo(semObj, "domainAdapter2domainInterface")
    if da == None:
        reportError("Domain interface must take a domain adapter on input.", semObj)
        ## Have to short-circuit to prevent weird errors from happening.
        return out
    else:
        attributes = a3t.getAttributes(da)
        out["parameters"] = attributes

    iCall = a3t.outOne(semObj, "domainInterface2Interface")
    i = a3t.outTwo(semObj, "domainInterface2Interface")
    if i == None:
        reportError("Domain interface must call a local interface.", semObj)
    else:
        name = a3t.evalAtom3Type(i.name)
        calls = a3t.gen2dict(iCall)
        iParameters = a3t.evalAtom3Type(i.parameters)
        calls["name"] = name
        out["calls"] = calls

        ## Constraints on interface call.
        testCall(calls["arguments"], out["parameters"], iParameters, iCall)

    deleteEmptyKeys(out)

    testValidName(out.get("name"), semObj)

    return out
示例#2
0
def testPrimitiveCall(out, primCall):
    primitive = a3t.outOne(primCall)
    theirParams = a3t.evalAtom3Type(primitive.parameters)
    myArgs = a3t.evalAtom3Type(primCall.arguments)
    myLocals = a3t.evalAtom3Type(a3t.inOne(primCall).parameters)
    testCall(myArgs, myLocals, theirParams, primCall)

    if out["delay"] < 0:
        reportError("Delay must be >0.", primCall)
示例#3
0
def getPrimitiveCalls(interface, parameters):
    semCalls = a3t.filterOutboundEdges(interface, "interface2primitive")
    output = list()

    for semCall in semCalls:
        out = a3t.gen2dict(semCall)
        primitive = a3t.outOne(semCall)
        print semCall
        out["name"] = a3t.evalAtom3Type(primitive.name)

        testPrimitiveCall(out, semCall)
        output.append(out)

    return output
示例#4
0
def connection2dict(semObj):
    out = a3t.gen2dict(semObj)

    k = a3t.outOne(semObj, "connectionKeepalive")
    s = a3t.outOne(semObj, "connectionStartup")
    t = a3t.outOne(semObj, "connectionTerminate")

    for thing in (("keepalive", k), ("startup", s), ("terminate", t)):
        if thing[1] != None:
            out[thing[0]] = a3t.gen2dict(thing[1])
            out[thing[0]]["name"] = a3t.evalAtom3Type(a3t.outOne(thing[1]).name)

            ## Get arguments for remote interface.
            myLocals = []
            myArgs = out[thing[0]]["arguments"]
            theirParams = a3t.evalAtom3Type(a3t.outOne(thing[1]).parameters)

            testCall(myArgs, myLocals, theirParams, thing[1])

            if thing[0] == "keepalive":
                testKeepalive(out["keepalive"], k)
                if out["keepalive"]["interval"] <= 0:
                    reportError("Keepalive interval should be >0.", k)

    addThreading(out, semObj)

    deleteEmptyKeys(out)

    if isinstance(semObj, SerialConnection):
        testSerial(out, semObj)
    else:
        reportError("Unbound connection type: {}".format(repr(semObj.__class__)), semObj)

    testValidName(out.get("name"), semObj)

    return out