Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accessing enums #39

Open
sachnk opened this issue Feb 6, 2018 · 1 comment
Open

accessing enums #39

sachnk opened this issue Feb 6, 2018 · 1 comment

Comments

@sachnk
Copy link

sachnk commented Feb 6, 2018

Hi --

Given the following enum in my schema:

enum MyEnum {
  foo @0;
  bar @1;
}

How do I access the corresponding numerical (or string) values for MyEnum? When I do the following:

...
const capnp = require("capnp");
const schema = capnp.import(__dirname + "/schema.capnp");
console.log(schema);

I see output that looks like:

capnp::Schema {
  typeId: '16659730972699922233',
  MyEnum: capnp::Schema { typeId: '11935489294493185729' },
...

So, there doesn't appear to be a way to access the values of the enum. Which means if I want to use the enum values in my node.js app, I can't really do it -- am I missing something?

Thanks!

@kentonv
Copy link
Member

kentonv commented Feb 6, 2018

Hi @sachnk,

In this Node.js implementation, enum values are represented by their string names, e.g. "foo" or "bar". So, there's no need to reference any global constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants