1

我有以下要编译的 .avdl 文件:

@namespace("com.test.foo.bar")
protocol PairStore {

    /* This is already defined in another namespace - "com.test.foo.nan" */
    record Pair {
        string item1;
        string item2;
    }

    record Registration {
        Pair inputPair;
        Pair outputPair;
        string indexURI;
    }
}

所以问题是我如何引用在创建时和in 中Pair定义的内容?com.test.foo.nanPairStoreRegistrationcom.test.foo.bar

4

2 回答 2

2

您应该能够从其他 avdl 文件中导入记录,如下所示:

@namespace("com.test.foo")
    protocol PairStore {

    /** No need to define the record again, 
        just import the file that has Pair defined*/
    import idl "bar.avdl";

    record Registration {
        /** And this is how you refer to that record. */
        com.test.bar.Pair inputPair;
        com.test.bar.Pair outputPair;
        string indexURI;
    }
}
于 2020-10-06T10:06:38.690 回答
0

在浏览了 Av​​ro 文档后,我终于找到了一个包含解决方案的示例。具体来说,这个例子

@namespace("com.test.foo")
protocol PairStore {

    /** Still need to define this record, but define it in the existing namespace. */
    @namespace("com.test.bar")
    record Pair {
        string item1;
        string item2;
    }

    record Registration {
        /** And this is how you refer to that record. */
        com.test.bar.Pair inputPair;
        com.test.bar.Pair outputPair;
        string indexURI;
    }
}
于 2013-09-03T15:03:55.567 回答