Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79824179 authored by Joe Onorato's avatar Joe Onorato Committed by Mike Lockwood
Browse files

Support putting Flattenables in Lists.

parent 6e0f981e
Loading
Loading
Loading
Loading
+32 −5
Original line number Diff line number Diff line
@@ -211,6 +211,12 @@ Type::CreatorName() const
    return "";
}

string
Type::RpcCreatorName() const
{
    return "";
}

string
Type::InstantiableName() const
{
@@ -910,6 +916,12 @@ UserDataType::CreatorName() const
    return QualifiedName() + ".CREATOR";
}

string
UserDataType::RpcCreatorName() const
{
    return QualifiedName() + ".RPC_CREATOR";
}

void
UserDataType::WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel, int flags)
{
@@ -1221,18 +1233,33 @@ void
GenericListType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
        Variable* data, int flags)
{
    Type* generic = GenericArgumentTypes()[0];
    if (generic == RPC_DATA_TYPE) {
        addTo->Add(new MethodCall(data, "putRpcDataList", 2, k, v));
    } else if (generic->RpcCreatorName() != "") {
        addTo->Add(new MethodCall(data, "putFlattenableList", 2, k, v));
    } else {
        addTo->Add(new MethodCall(data, "putList", 2, k, v));
    }
}

void
GenericListType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
        Variable* data, Variable** cl)
{
    Type* generic = GenericArgumentTypes()[0];
    if (generic == RPC_DATA_TYPE) {
        addTo->Add(new Assignment(v, new MethodCall(data, "getRpcDataList", 2, k)));
    } else if (generic->RpcCreatorName() != "") {
        addTo->Add(new Assignment(v, new MethodCall(data, "getFlattenableList", 2, k, 
                        new LiteralExpression(generic->RpcCreatorName()))));
    } else {
        string classArg = GenericArgumentTypes()[0]->QualifiedName();
        classArg += ".class";
        addTo->Add(new Assignment(v, new MethodCall(data, "getList", 2, k,
                        new LiteralExpression(classArg))));
    }
}


// ================================================================
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public:
    
    virtual string  ImportType() const;
    virtual string  CreatorName() const;
    virtual string  RpcCreatorName() const;
    virtual string  InstantiableName() const;

    virtual void    WriteToParcel(StatementBlock* addTo, Variable* v,
@@ -358,6 +359,7 @@ public:
                            const string& declFile = "", int declLine = -1);

    virtual string  CreatorName() const;
    virtual string  RpcCreatorName() const;

    virtual void    WriteToParcel(StatementBlock* addTo, Variable* v,
                                    Variable* parcel, int flags);