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)
check_PROGRAMS = capnp-test capnp-evolution-test
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.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 = \
src/kj/common-test.c++ \
src/kj/memory-test.c++ \
......
......@@ -496,7 +496,7 @@ private:
break;
}
case schema::Field::GROUP:
getSlots(schema.getDependency(proto.getGroup().getTypeId()).asStruct(), slots);
getSlots(field.getType().asStruct(), slots);
break;
}
}
......
......@@ -453,7 +453,7 @@ uint getOrdinal(StructSchema::Field field) {
KJ_ASSERT(proto.isGroup());
auto group = field.getContainingStruct().getDependency(proto.getGroup().getTypeId()).asStruct();
auto group = field.getType().asStruct();
return getOrdinal(group.getFields()[0]);
}
......@@ -462,8 +462,7 @@ Orphan<DynamicStruct> makeExampleStruct(
void checkExampleStruct(DynamicStruct::Reader reader, uint sharedOrdinalCount);
Orphan<DynamicValue> makeExampleValue(
Orphanage orphanage, Schema scope, uint ordinal, schema::Type::Reader type,
uint sharedOrdinalCount) {
Orphanage orphanage, uint ordinal, Type type, uint sharedOrdinalCount) {
switch (type.which()) {
case schema::Type::INT32: return ordinal * 47327;
case schema::Type::FLOAT64: return ordinal * 313.25;
......@@ -472,7 +471,7 @@ Orphan<DynamicValue> makeExampleValue(
case schema::Type::BOOL: return ordinal % 2 == 0;
case schema::Type::TEXT: return orphanage.newOrphanCopy(Text::Reader(kj::str(ordinal)));
case schema::Type::STRUCT: {
auto structType = scope.getDependency(type.getStruct().getTypeId()).asStruct();
auto structType = type.asStruct();
auto result = orphanage.newOrphan(structType);
auto builder = result.get();
......@@ -482,23 +481,22 @@ Orphan<DynamicValue> makeExampleValue(
} else {
// Type is "Int32Struct" or the like.
auto field = structType.getFieldByName("f0");
builder.adopt(field, makeExampleValue(orphanage, structType, ordinal,
field.getProto().getSlot().getType(),
sharedOrdinalCount));
builder.adopt(field, makeExampleValue(
orphanage, ordinal, field.getType(), sharedOrdinalCount));
}
return kj::mv(result);
}
case schema::Type::ENUM: {
auto enumerants = scope.getDependency(type.getEnum().getTypeId()).asEnum().getEnumerants();
auto enumerants = type.asEnum().getEnumerants();
return DynamicEnum(enumerants[ordinal %enumerants.size()]);
}
case schema::Type::LIST: {
auto elementType = type.getList().getElementType();
auto listType = ListSchema::of(elementType, scope);
auto listType = type.asList();
auto elementType = listType.getElementType();
auto result = orphanage.newOrphan(listType, 1);
result.get().adopt(0, makeExampleValue(
orphanage, scope, ordinal, elementType, sharedOrdinalCount));
orphanage, ordinal, elementType, sharedOrdinalCount));
return kj::mv(result);
}
default:
......@@ -551,14 +549,13 @@ void setExampleField(DynamicStruct::Builder builder, StructSchema::Field field,
switch (fieldProto.which()) {
case schema::Field::SLOT:
builder.adopt(field, makeExampleValue(
Orphanage::getForMessageContaining(builder), field.getContainingStruct(),
getOrdinal(field), fieldProto.getSlot().getType(), sharedOrdinalCount));
Orphanage::getForMessageContaining(builder),
getOrdinal(field), field.getType(), sharedOrdinalCount));
break;
case schema::Field::GROUP:
builder.adopt(field, makeExampleStruct(
Orphanage::getForMessageContaining(builder),
field.getContainingStruct().getDependency(fieldProto.getGroup().getTypeId()).asStruct(),
sharedOrdinalCount));
field.getType().asStruct(), sharedOrdinalCount));
break;
}
}
......
......@@ -37,9 +37,8 @@ Request<DynamicStruct, DynamicStruct> DynamicCapability::Client::newRequest(
KJ_REQUIRE(schema.extends(methodInterface), "Interface does not implement this method.");
auto proto = method.getProto();
auto paramType = methodInterface.getDependency(proto.getParamStructType()).asStruct();
auto resultType = methodInterface.getDependency(proto.getResultStructType()).asStruct();
auto paramType = method.getParamType();
auto resultType = method.getResultType();
auto typeless = hook->newCall(
methodInterface.getProto().getId(), method.getIndex(), sizeHint);
......@@ -60,10 +59,8 @@ kj::Promise<void> DynamicCapability::Server::dispatchCall(
auto methods = interface->getMethods();
if (methodId < methods.size()) {
auto method = methods[methodId];
auto proto = method.getProto();
return call(method, CallContext<DynamicStruct, DynamicStruct>(*context.hook,
interface->getDependency(proto.getParamStructType()).asStruct(),
interface->getDependency(proto.getResultStructType()).asStruct()));
method.getParamType(), method.getResultType()));
} else {
return internalUnimplemented(
interface->getProto().getDisplayName().cStr(), interfaceId, methodId);
......
......@@ -52,7 +52,7 @@ struct RawBrandedSchema {
// 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.
const RawSchema* generic = nullptr;
const RawSchema* generic;
// Generic type which we're branding.
struct Binding {
......@@ -71,7 +71,7 @@ struct RawBrandedSchema {
// 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.
struct Dependency {
......@@ -79,12 +79,12 @@ struct RawBrandedSchema {
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
// are branded are included in this map; if a dependency is missing, use its `defaultBrand`.
uint32_t scopeCount = 0;
uint32_t dependencyCount = 0;
uint32_t scopeCount;
uint32_t dependencyCount;
enum class DepKind {
// Component of a Dependency::location. Specifies what sort of dependency this is.
......@@ -121,7 +121,7 @@ struct RawBrandedSchema {
virtual void init(const RawBrandedSchema* generic) const = 0;
};
const Initializer* lazyInitializer = nullptr;
const Initializer* lazyInitializer;
// Lazy initializer, invoked by ensureInitialized().
inline void ensureInitialized() const {
......
......@@ -635,7 +635,7 @@ StructSchema InterfaceSchema::Method::getResultType() const {
auto proto = getProto();
uint location = _::RawBrandedSchema::makeDepLocation(
_::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 {
......
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