Hi,
I wonder the difference between annotation of struct type and the normal
struct. Could the annotation be decoded as the normal data?
I could easily get the name and the value from the normal struct, eg. Foo1,
but could not get those from annotation of struct type, eg. testFoo.
struct Foo{
annobar1 @0 : Text = "d";
annobar2 @1: Text = "e";
}
annotation testFoo(*): Foo;
struct Foo1{
bar1 @0: Bool = false $testFoo();
bar2 @1: Bool = true;
}
The urgent problem need to be solved is, how I can get the name and value
in struct Foo from annotation testFoo.
The ideal output is
annobar1="d", annobar2= "e" . like the nomal data.
åš 2018幎6æ20æ¥ææäž UTC+8äžå12:50:32ïŒKenton VardaåéïŒ
Post by 'Kenton Varda' via Cap'n ProtoHi,
The `struct` value is another AnyPointer. In JavaScript you should get a
buffer there, which you can parse as the actual struct type. In C++ you can
use anyPointer.as<MyStructType>() to interpret it as that type.
-Kenton
Hi Kenton,
I have got the buffer value, which is " type = (struct = <opaque
pointer>)" and doesn't contain the value in the struct. How can I get the
value?
-Kiki
åš 2018幎6æ16æ¥ææå
UTC+8äžå3:30:21ïŒKenton VardaåéïŒ
Post by 'Kenton Varda' via Cap'n ProtoHi kikipcr,
The buffer contains a Cap'n Proto message. You can parse it as your
annotation type.
-Kenton
Hi Kenton,
And I have got the value of the annotation $testFoo() . The type of
dynamic value is any_pointer. But I only could obtain the buffer value,
like this.
<Buffer 00 00 00 00 05 00 00 00 00 00 00 00 01 00 03 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00>
How to transfer to string words?
kiki
åš 2018幎6æ12æ¥ææäº UTC+8äžå9:13:35ïŒKenton VardaåéïŒ
Post by 'Kenton Varda' via Cap'n ProtoHi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node
API. :(
-Kenton
Post by k***@gmail.comIn xx.capnp,
...
struct Foo{
}
annotation testFoo(*): Foo;
struct Foo1{
}
...
I get the annotation value in struct Foo1 when I meet the $testFoo()
in capnp-node-v8.
Then I use the "toString" function, the name in annotation is
"void/bool/...",not the name like struct Foo1 whose name is "bar1".
How can I get the name "bar" and value "d" when I get the
schema::Annotation::Reader for $testFoo()?
--
You received this message because you are subscribed to the Google
Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it,
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google
Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.