Great! I think that unblocks me. Thanks for explaining the fix -- it helps
me get the code.

On Sun, May 1, 2016 at 5:34 PM, Kenton Varda <[email protected]> wrote:

> OK, I've fixed this too:
>
>
> https://github.com/sandstorm-io/capnproto/commit/9fb7d65a407e6c4c8f0ac9203549428964629e6b
>
> The problem was that newOrphan<DynamicStruct>() needs to be passed a
> StructSchema as the first parameter, to tell it what type of struct to
> construct. Handler<DynamicStruct> needed to be special-cased to support
> this.
>
> -Kenton
>
> On Sun, May 1, 2016 at 3:32 PM, Harris Hancock <[email protected]> wrote:
>
>> Awesome, thank you Kenton!
>>
>> Alas, I ran into a second problem in the same vein:
>>
>> `Handler<DynamicStruct>` has a default orphanage decode implementation
>> which calls `orphanage.newOrphan<DynamicStruct>()` (json.h:326). This
>> function tries to reach into `DynamicStruct::_capnpPrivate`, which doesn't
>> exist.
>>
>> MSVC complains:
>>
>> https://gist.github.com/harrishancock/1defbad9b30a9b2c65105e50bf7a4788
>>
>> The following code:
>>
>>   Orphanage orphanage;
>>   auto orphan = orphanage.newOrphan<DynamicStruct>();
>>
>> makes gcc complain, too:
>>
>> https://gist.github.com/harrishancock/753d36ecec1831a2cf872cbd3142c15d
>>
>> On Sun, May 1, 2016 at 1:08 PM, Kenton Varda <[email protected]> wrote:
>>
>>> Thanks, I've fixed this, and came away with rather more yak hair than
>>> expected...
>>>
>>>
>>> https://github.com/sandstorm-io/capnproto/commit/e1f1737acebe8d42365a18074c0287fde7f2de85
>>>
>>> -Kenton
>>>
>>> On Sun, May 1, 2016 at 11:22 AM, Harris Hancock <[email protected]>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> In capnp/compat/json.h:365-382, there's a snippet of code that goes
>>>> like this:
>>>>
>>>> class JsonCodec::Handler<T, Style::CAPABILITY> {
>>>>   T::Client decode(...);
>>>>   Orphan<DynamicValue> decodeBase(...) {
>>>>     return decode(...); // ERROR, can't convert T::Client to
>>>> Orphan<DynamicValue>
>>>>   }
>>>> };
>>>>
>>>> GCC accepts this, but the line marked ERROR results in a compilation
>>>> error under MSVC (compiled using my VS2015 branch rebased onto master):
>>>>
>>>>
>>>> c:\users\vortr\git\sandstorm\capnproto\c++\src\capnp\compat\json.h(379):
>>>> error C2440: 'return': cannot convert from
>>>> 'capnp::DynamicCapability::Client' to 'capnp::Orphan<capnp::DynamicValue>'
>>>> [C:\Users\vortr\git\sandstorm\build-capnp-vs2015\src\capnp\capnp-json.vcxproj]
>>>>
>>>> I couldn't see any clear way that a `Client` is convertible to an
>>>> `Orphan<DynamicValue>`, and started wondering if the code is erroneous,
>>>> despite it compiling under gcc. Handler<DynamicCapability> is only
>>>> instantiated from an inline function overload
>>>> (`JsonCodec::addTypeHandler(InterfaceSchema, ...)`) that is itself never
>>>> called from any test case. Perhaps MSVC is eagerly compiling something that
>>>> gcc optimizes away early.
>>>>
>>>> To try and verify this, I stubbed out the following test case to
>>>> json-test.c++, which exercises the `addTypeHandler` overload in question:
>>>>
>>>> https://gist.github.com/harrishancock/e16293723ece14910bc7e41ab2a6bdb4
>>>>
>>>> Compiling this under gcc 5.3.1 (Ubuntu 16.04) resulted in a very
>>>> similar compilation error to the one that MSVC displayed:
>>>>
>>>> /home/harris/git/sandstorm/capnproto/c++/src/capnp/compat/json.h:379:31:
>>>> error: could not convert ... from
>>>> ‘capnproto_test::capnp::test::TestInterface::Client’ to
>>>> ‘capnp::Orphan<capnp::DynamicValue>’
>>>>
>>>> Full error log here:
>>>> https://gist.github.com/harrishancock/6fb180b2ea52683aa4171dc63c4e1908
>>>>
>>>> If anyone (Kenton?) can confirm my test case is written correctly
>>>> (runtime behavior notwithstanding), I'll go ahead and open an issue on
>>>> GitHub.
>>>> Harris
>>>>
>>>> --
>>>> 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 [email protected].
>>>> 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 [email protected].
>> 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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to