Exemplo n.º 1
0
def MakeVectorCall(return_type, func_name, arg_type):
    """Convert a call like glVertex3f to glVertex3fv."""
    vec_func = apiutil.VectorFunction(func_name)
    params = apiutil.Parameters(vec_func)
    assert len(params) == 1
    (arg_name, vecType, vecSize) = params[0]

    if arg_type == "GLdouble" or arg_type == "GLclampd":
        print("#ifdef CR_UNALIGNED_ACCESS_OKAY")
        print("\tpState->pDispatchTbl->%s((%s) pState->pbUnpackData);" %
              (vec_func, vecType))
        print("#else")
        for index in range(0, vecSize):
            print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(pState, " +
                  repr(index * 8) + ");")
        if return_type != "void":
            print("\t(void) pState->pDispatchTbl->%s(" % func_name, end="")
        else:
            print("\tpState->pDispatchTbl->%s(" % func_name, end="")
        for index in range(0, vecSize):
            print("v" + repr(index), end="")
            if index != vecSize - 1:
                print(",", end=" ")
        print(");")
        print("#endif")
    else:
        print("\tpState->pDispatchTbl->%s((%s) pState->pbUnpackData);" %
              (vec_func, vecType))
Exemplo n.º 2
0
def MakeVectorCall(return_type, func_name, arg_type):
    """Convert a call like glVertex3f to glVertex3fv."""
    vec_func = apiutil.VectorFunction(func_name)
    params = apiutil.Parameters(vec_func)
    assert len(params) == 1
    (arg_name, vecType, vecSize) = params[0]

    if arg_type == "GLdouble" or arg_type == "GLclampd":
        print "#ifdef CR_UNALIGNED_ACCESS_OKAY"
        print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func,
                                                               vecType)
        print "#else"
        for index in range(0, vecSize):
            print "\tGLdouble v" + ` index ` + " = READ_DOUBLE(", ` index * 8 `, ");"
        if return_type != "void":
            print "\t(void) cr_unpackDispatch.%s(" % func_name,
        else:
            print "\tcr_unpackDispatch.%s(" % func_name,
        for index in range(0, vecSize):
            print "v" + ` index `,
            if index != vecSize - 1:
                print ",",
        print ");"
        print "#endif"
    else:
        print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func,
                                                               vecType)
Exemplo n.º 3
0
            or apiutil.FindSpecial("unpacker", func_name)):
        continue

    params = apiutil.Parameters(func_name)
    return_type = apiutil.ReturnType(func_name)

    packet_length = apiutil.PacketLength(params)
    print("static void crUnpack%s(PCrUnpackerState pState)" % func_name)
    print("{")
    if ("get" in apiutil.Properties(func_name)):
        print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" %
              getWritebackPointerOffset(return_type, params))
    elif packet_length != 0:
        print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" % packet_length)

    vector_func = apiutil.VectorFunction(func_name)
    if (vector_func and len(apiutil.Parameters(vector_func)) == 1):
        MakeVectorCall(return_type, func_name, params[0][1])
    else:
        MakeNormalCall(return_type, func_name, params)
    if packet_length == 0:
        print("\tINCR_DATA_PTR_NO_ARGS(pState);")
    else:
        print("\tINCR_DATA_PTR(pState, %d);" % packet_length)
    print("}\n")

#
# Emit some code
#
print(""" 
CR_UNPACK_BUFFER_TYPE crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes)