Define a type alias in Cap'n Proto

164 Views Asked by At

I do not understand how one would export a type alias in Cap'n Proto.

The simplest example I can think of is a point cloud. Suppose we have a schema such as

struct Point {
    x @0: Float32 = 0;
    y @1: Float32 = 0;
}

and then I want to also export a list of those points as a fixed type:

struct Point {
    x @0: Float32 = 0;
    y @1: Float32 = 0;
}

using PointCloud = List(Point);

It seems to me (based on the generated code) that the PointCloud type is not exported as part of the schema. It seems that that PointCloud is only usable interally in the schema file.

How can I export this alias so that it is usable externally?

1

There are 1 best solutions below

1
bremen_matt On

I stumbled across the roadmap, and there there is the statement:

Type aliases: Ability to define a type which is just an alias of some other type, and have it show up as e.g. a typedef in languages that support that. (The current using keyword is intended only for local use and does not affect code generation.)

So perhaps this is the answer to my question... It is simply not currently supported.