Discussion:
[capnproto] Get the annotation name and value
k***@gmail.com
2018-06-11 07:35:06 UTC
Permalink
In xx.capnp,
...
struct Foo{
bar @0 : Text = "d";
}

annotation testFoo(*): Foo;

struct Foo1{
bar1 @0: Bool $testFoo();
}
...

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, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
'Kenton Varda' via Cap'n Proto
2018-06-15 19:29:40 UTC
Permalink
Hi 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写道
Hi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node API.
:(
-Kenton
Post by k***@gmail.com
In 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, 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.
k***@gmail.com
2018-06-19 12:36:27 UTC
Permalink
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 Proto
Hi 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 Proto
Hi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node
API. :(
-Kenton
Post by k***@gmail.com
In 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, 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.
'Kenton Varda' via Cap'n Proto
2018-06-19 16:49:50 UTC
Permalink
Hi,

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 Proto
Hi 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 Proto
Hi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node
API. :(
-Kenton
Post by k***@gmail.com
In 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, 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
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.
k***@gmail.com
2018-06-21 02:33:55 UTC
Permalink
Hi,
I wonder the difference between annotation of struct type and the normal
struct. Could the annotation be decoded as the normal data?

And the most important thing is, 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.

struct Foo{
annobar1 @0 : Text = "d";

}

annotation testFoo(*): Foo;

struct Foo1{
bar1 @0: Bool = false $testFoo();
bar2 @1: Bool = true;
}

-Kiki

圚 2018幎6月20日星期䞉 UTC+8䞊午12:50:32Kenton Varda写道
Post by 'Kenton Varda' via Cap'n Proto
Hi,
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 Proto
Hi 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 Proto
Hi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node
API. :(
-Kenton
Post by k***@gmail.com
In 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.
k***@gmail.com
2018-06-21 02:43:18 UTC
Permalink
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 Proto
Hi,
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 Proto
Hi 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 Proto
Hi kikipcr,
Sorry, but annotations are not currently exposed from the capnp-node
API. :(
-Kenton
Post by k***@gmail.com
In 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.
Loading...