Commit 4692a669 authored by Kenton Varda's avatar Kenton Varda

Fix build for C++11.

1) Apparently mixing member defaults and initializer lists is a C++14 thing.
2) My test script compiles with -Werror which errors out on calls to now-deprecated getDependency().
parent 9b91e8ce
...@@ -333,7 +333,7 @@ BUILT_SOURCES = $(test_capnpc_outputs) ...@@ -333,7 +333,7 @@ BUILT_SOURCES = $(test_capnpc_outputs)
check_PROGRAMS = capnp-test capnp-evolution-test check_PROGRAMS = capnp-test capnp-evolution-test
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la \ capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la \
libcapnpc.la libcapnp-rpc.la libcapnp.la libkj-async.la libkj.la libcapnpc.la libcapnp-rpc.la libcapnp.la libkj-async.la libkj.la
capnp_test_CPPFLAGS = -Igtest/include -I$(srcdir)/gtest/include capnp_test_CPPFLAGS = -Wno-deprecated-declarations -Igtest/include -I$(srcdir)/gtest/include
capnp_test_SOURCES = \ capnp_test_SOURCES = \
src/kj/common-test.c++ \ src/kj/common-test.c++ \
src/kj/memory-test.c++ \ src/kj/memory-test.c++ \
......
...@@ -496,7 +496,7 @@ private: ...@@ -496,7 +496,7 @@ private:
break; break;
} }
case schema::Field::GROUP: case schema::Field::GROUP:
getSlots(schema.getDependency(proto.getGroup().getTypeId()).asStruct(), slots); getSlots(field.getType().asStruct(), slots);
break; break;
} }
} }
......
...@@ -453,7 +453,7 @@ uint getOrdinal(StructSchema::Field field) { ...@@ -453,7 +453,7 @@ uint getOrdinal(StructSchema::Field field) {
KJ_ASSERT(proto.isGroup()); KJ_ASSERT(proto.isGroup());
auto group = field.getContainingStruct().getDependency(proto.getGroup().getTypeId()).asStruct(); auto group = field.getType().asStruct();
return getOrdinal(group.getFields()[0]); return getOrdinal(group.getFields()[0]);
} }
...@@ -462,8 +462,7 @@ Orphan<DynamicStruct> makeExampleStruct( ...@@ -462,8 +462,7 @@ Orphan<DynamicStruct> makeExampleStruct(
void checkExampleStruct(DynamicStruct::Reader reader, uint sharedOrdinalCount); void checkExampleStruct(DynamicStruct::Reader reader, uint sharedOrdinalCount);
Orphan<DynamicValue> makeExampleValue( Orphan<DynamicValue> makeExampleValue(
Orphanage orphanage, Schema scope, uint ordinal, schema::Type::Reader type, Orphanage orphanage, uint ordinal, Type type, uint sharedOrdinalCount) {
uint sharedOrdinalCount) {
switch (type.which()) { switch (type.which()) {
case schema::Type::INT32: return ordinal * 47327; case schema::Type::INT32: return ordinal * 47327;
case schema::Type::FLOAT64: return ordinal * 313.25; case schema::Type::FLOAT64: return ordinal * 313.25;
...@@ -472,7 +471,7 @@ Orphan<DynamicValue> makeExampleValue( ...@@ -472,7 +471,7 @@ Orphan<DynamicValue> makeExampleValue(
case schema::Type::BOOL: return ordinal % 2 == 0; case schema::Type::BOOL: return ordinal % 2 == 0;
case schema::Type::TEXT: return orphanage.newOrphanCopy(Text::Reader(kj::str(ordinal))); case schema::Type::TEXT: return orphanage.newOrphanCopy(Text::Reader(kj::str(ordinal)));
case schema::Type::STRUCT: { case schema::Type::STRUCT: {
auto structType = scope.getDependency(type.getStruct().getTypeId()).asStruct(); auto structType = type.asStruct();
auto result = orphanage.newOrphan(structType); auto result = orphanage.newOrphan(structType);
auto builder = result.get(); auto builder = result.get();
...@@ -482,23 +481,22 @@ Orphan<DynamicValue> makeExampleValue( ...@@ -482,23 +481,22 @@ Orphan<DynamicValue> makeExampleValue(
} else { } else {
// Type is "Int32Struct" or the like. // Type is "Int32Struct" or the like.
auto field = structType.getFieldByName("f0"); auto field = structType.getFieldByName("f0");
builder.adopt(field, makeExampleValue(orphanage, structType, ordinal, builder.adopt(field, makeExampleValue(
field.getProto().getSlot().getType(), orphanage, ordinal, field.getType(), sharedOrdinalCount));
sharedOrdinalCount));
} }
return kj::mv(result); return kj::mv(result);
} }
case schema::Type::ENUM: { case schema::Type::ENUM: {
auto enumerants = scope.getDependency(type.getEnum().getTypeId()).asEnum().getEnumerants(); auto enumerants = type.asEnum().getEnumerants();
return DynamicEnum(enumerants[ordinal %enumerants.size()]); return DynamicEnum(enumerants[ordinal %enumerants.size()]);
} }
case schema::Type::LIST: { case schema::Type::LIST: {
auto elementType = type.getList().getElementType(); auto listType = type.asList();
auto listType = ListSchema::of(elementType, scope); auto elementType = listType.getElementType();
auto result = orphanage.newOrphan(listType, 1); auto result = orphanage.newOrphan(listType, 1);
result.get().adopt(0, makeExampleValue( result.get().adopt(0, makeExampleValue(
orphanage, scope, ordinal, elementType, sharedOrdinalCount)); orphanage, ordinal, elementType, sharedOrdinalCount));
return kj::mv(result); return kj::mv(result);
} }
default: default:
...@@ -551,14 +549,13 @@ void setExampleField(DynamicStruct::Builder builder, StructSchema::Field field, ...@@ -551,14 +549,13 @@ void setExampleField(DynamicStruct::Builder builder, StructSchema::Field field,
switch (fieldProto.which()) { switch (fieldProto.which()) {
case schema::Field::SLOT: case schema::Field::SLOT:
builder.adopt(field, makeExampleValue( builder.adopt(field, makeExampleValue(
Orphanage::getForMessageContaining(builder), field.getContainingStruct(), Orphanage::getForMessageContaining(builder),
getOrdinal(field), fieldProto.getSlot().getType(), sharedOrdinalCount)); getOrdinal(field), field.getType(), sharedOrdinalCount));
break; break;
case schema::Field::GROUP: case schema::Field::GROUP:
builder.adopt(field, makeExampleStruct( builder.adopt(field, makeExampleStruct(
Orphanage::getForMessageContaining(builder), Orphanage::getForMessageContaining(builder),
field.getContainingStruct().getDependency(fieldProto.getGroup().getTypeId()).asStruct(), field.getType().asStruct(), sharedOrdinalCount));
sharedOrdinalCount));
break; break;
} }
} }
......
...@@ -37,9 +37,8 @@ Request<DynamicStruct, DynamicStruct> DynamicCapability::Client::newRequest( ...@@ -37,9 +37,8 @@ Request<DynamicStruct, DynamicStruct> DynamicCapability::Client::newRequest(
KJ_REQUIRE(schema.extends(methodInterface), "Interface does not implement this method."); KJ_REQUIRE(schema.extends(methodInterface), "Interface does not implement this method.");
auto proto = method.getProto(); auto paramType = method.getParamType();
auto paramType = methodInterface.getDependency(proto.getParamStructType()).asStruct(); auto resultType = method.getResultType();
auto resultType = methodInterface.getDependency(proto.getResultStructType()).asStruct();
auto typeless = hook->newCall( auto typeless = hook->newCall(
methodInterface.getProto().getId(), method.getIndex(), sizeHint); methodInterface.getProto().getId(), method.getIndex(), sizeHint);
...@@ -60,10 +59,8 @@ kj::Promise<void> DynamicCapability::Server::dispatchCall( ...@@ -60,10 +59,8 @@ kj::Promise<void> DynamicCapability::Server::dispatchCall(
auto methods = interface->getMethods(); auto methods = interface->getMethods();
if (methodId < methods.size()) { if (methodId < methods.size()) {
auto method = methods[methodId]; auto method = methods[methodId];
auto proto = method.getProto();
return call(method, CallContext<DynamicStruct, DynamicStruct>(*context.hook, return call(method, CallContext<DynamicStruct, DynamicStruct>(*context.hook,
interface->getDependency(proto.getParamStructType()).asStruct(), method.getParamType(), method.getResultType()));
interface->getDependency(proto.getResultStructType()).asStruct()));
} else { } else {
return internalUnimplemented( return internalUnimplemented(
interface->getProto().getDisplayName().cStr(), interfaceId, methodId); interface->getProto().getDisplayName().cStr(), interfaceId, methodId);
......
...@@ -52,7 +52,7 @@ struct RawBrandedSchema { ...@@ -52,7 +52,7 @@ struct RawBrandedSchema {
// every _instance_ of a generic type -- or, at least, every instance that is actually used. For // every _instance_ of a generic type -- or, at least, every instance that is actually used. For
// generated-code types, we use template magic to initialize these. // generated-code types, we use template magic to initialize these.
const RawSchema* generic = nullptr; const RawSchema* generic;
// Generic type which we're branding. // Generic type which we're branding.
struct Binding { struct Binding {
...@@ -71,7 +71,7 @@ struct RawBrandedSchema { ...@@ -71,7 +71,7 @@ struct RawBrandedSchema {
// Bindings for those parameters. // Bindings for those parameters.
}; };
const Scope* scopes = nullptr; const Scope* scopes;
// Array of enclosing scopes for which generic variables have been bound, sorted by type ID. // Array of enclosing scopes for which generic variables have been bound, sorted by type ID.
struct Dependency { struct Dependency {
...@@ -79,12 +79,12 @@ struct RawBrandedSchema { ...@@ -79,12 +79,12 @@ struct RawBrandedSchema {
const RawBrandedSchema* schema; const RawBrandedSchema* schema;
}; };
const Dependency* dependencies = nullptr; const Dependency* dependencies;
// Map of branded schemas for dependencies of this type, given our brand. Only dependencies that // Map of branded schemas for dependencies of this type, given our brand. Only dependencies that
// are branded are included in this map; if a dependency is missing, use its `defaultBrand`. // are branded are included in this map; if a dependency is missing, use its `defaultBrand`.
uint32_t scopeCount = 0; uint32_t scopeCount;
uint32_t dependencyCount = 0; uint32_t dependencyCount;
enum class DepKind { enum class DepKind {
// Component of a Dependency::location. Specifies what sort of dependency this is. // Component of a Dependency::location. Specifies what sort of dependency this is.
...@@ -121,7 +121,7 @@ struct RawBrandedSchema { ...@@ -121,7 +121,7 @@ struct RawBrandedSchema {
virtual void init(const RawBrandedSchema* generic) const = 0; virtual void init(const RawBrandedSchema* generic) const = 0;
}; };
const Initializer* lazyInitializer = nullptr; const Initializer* lazyInitializer;
// Lazy initializer, invoked by ensureInitialized(). // Lazy initializer, invoked by ensureInitialized().
inline void ensureInitialized() const { inline void ensureInitialized() const {
......
...@@ -635,7 +635,7 @@ StructSchema InterfaceSchema::Method::getResultType() const { ...@@ -635,7 +635,7 @@ StructSchema InterfaceSchema::Method::getResultType() const {
auto proto = getProto(); auto proto = getProto();
uint location = _::RawBrandedSchema::makeDepLocation( uint location = _::RawBrandedSchema::makeDepLocation(
_::RawBrandedSchema::DepKind::METHOD_RESULTS, ordinal); _::RawBrandedSchema::DepKind::METHOD_RESULTS, ordinal);
return parent.getDependency(proto.getParamStructType(), location).asStruct(); return parent.getDependency(proto.getResultStructType(), location).asStruct();
} }
InterfaceSchema InterfaceSchema::SuperclassList::operator[](uint index) const { InterfaceSchema InterfaceSchema::SuperclassList::operator[](uint index) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment