You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/01/12 20:01:36 UTC
[2/2] git commit: THRIFT-2130 D library/test: parts of "make check"
code do not compile with recent dmd-2.062 through dmd-2.064alpha Patch: David
Nadlinger
THRIFT-2130 D library/test: parts of "make check" code do not compile with recent dmd-2.062 through dmd-2.064alpha
Patch: David Nadlinger
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/62320141
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/62320141
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/62320141
Branch: refs/heads/master
Commit: 623201412a36471f5bd92b16290028fc03a2b88d
Parents: 38391a7
Author: Roger Meier <ro...@apache.org>
Authored: Sun Jan 12 20:00:31 2014 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Sun Jan 12 20:00:31 2014 +0100
----------------------------------------------------------------------
lib/d/src/thrift/codegen/base.d | 11 +++++------
lib/d/src/thrift/internal/codegen.d | 13 +++++++++++++
lib/d/src/thrift/util/hashset.d | 7 ++++---
3 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/62320141/lib/d/src/thrift/codegen/base.d
----------------------------------------------------------------------
diff --git a/lib/d/src/thrift/codegen/base.d b/lib/d/src/thrift/codegen/base.d
index 95e09ff..a9150d7 100644
--- a/lib/d/src/thrift/codegen/base.d
+++ b/lib/d/src/thrift/codegen/base.d
@@ -358,7 +358,7 @@ template BaseService(T) if (isDerivedService!T) {
mixin template TStructHelpers(alias fieldMetaData = cast(TFieldMeta[])null) if (
is(typeof(fieldMetaData) : TFieldMeta[])
) {
- import std.algorithm : canFind;
+ import std.algorithm : any;
import thrift.codegen.base;
import thrift.internal.codegen : isNullable, MemberType, mergeFieldMeta,
FieldNames;
@@ -459,7 +459,7 @@ mixin template TStructHelpers(alias fieldMetaData = cast(TFieldMeta[])null) if (
return true;
}
- static if (canFind!`!a.defaultValue.empty`(mergeFieldMeta!(This, fieldMetaData))) {
+ static if (any!`!a.defaultValue.empty`(mergeFieldMeta!(This, fieldMetaData))) {
static if (is(This _ == class)) {
this() {
mixin(thriftFieldInitCode!(mergeFieldMeta!(This, fieldMetaData))("this"));
@@ -500,10 +500,10 @@ string thriftFieldInitCode(alias fieldMeta)(string thisName) {
return code;
}
-version (unittest) {
+unittest {
// Cannot make this nested in the unittest block due to a »no size yet for
// forward reference« error.
- struct Foo {
+ static struct Foo {
string a;
int b;
int c;
@@ -514,8 +514,7 @@ version (unittest) {
TFieldMeta("c", 3, TReq.REQUIRED, "4")
]);
}
-}
-unittest {
+
auto f = Foo();
f.set!"b"(12345);
http://git-wip-us.apache.org/repos/asf/thrift/blob/62320141/lib/d/src/thrift/internal/codegen.d
----------------------------------------------------------------------
diff --git a/lib/d/src/thrift/internal/codegen.d b/lib/d/src/thrift/internal/codegen.d
index aae65bb..85f9d18 100644
--- a/lib/d/src/thrift/internal/codegen.d
+++ b/lib/d/src/thrift/internal/codegen.d
@@ -19,6 +19,7 @@
module thrift.internal.codegen;
+import std.algorithm : canFind;
import std.traits : InterfacesTuple, isSomeFunction, isSomeString;
import std.typetuple : staticIndexOf, staticMap, NoDuplicates, TypeTuple;
import thrift.codegen.base;
@@ -178,6 +179,7 @@ template isValueMember(T, string name) {
template FieldNames(T, alias fieldMetaData = cast(TFieldMeta[])null) {
alias StaticFilter!(
All!(
+ doesNotReadMembers,
PApply!(isValueMember, T),
PApply!(notIgnored, T, PApplySkip, fieldMetaData)
),
@@ -185,6 +187,17 @@ template FieldNames(T, alias fieldMetaData = cast(TFieldMeta[])null) {
) FieldNames;
}
+/*
+ * true if the passed member name is not a method generated by the
+ * TStructHelpers template that in its implementations queries the struct
+ * members.
+ *
+ * Kludge used internally to break a cycle caused a DMD forward reference
+ * regression, see THRIFT-2130.
+ */
+enum doesNotReadMembers(string name) = !["opEquals", "thriftOpEqualsImpl",
+ "toString", "thriftToStringImpl"].canFind(name);
+
template derivedMembers(T) {
alias TypeTuple!(__traits(derivedMembers, T)) derivedMembers;
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/62320141/lib/d/src/thrift/util/hashset.d
----------------------------------------------------------------------
diff --git a/lib/d/src/thrift/util/hashset.d b/lib/d/src/thrift/util/hashset.d
index 5ef97f9..3fa466e 100644
--- a/lib/d/src/thrift/util/hashset.d
+++ b/lib/d/src/thrift/util/hashset.d
@@ -23,6 +23,8 @@ import std.conv : to;
import std.traits : isImplicitlyConvertible, ParameterTypeTuple;
import std.range : ElementType, isInputRange;
+struct Void {}
+
/**
* A quickly hacked together hash set implementation backed by built-in
* associative arrays to have something to compile Thrift's set<> to until
@@ -41,7 +43,7 @@ final class HashSet(E) {
///
void insert(Stuff)(Stuff stuff) if (isImplicitlyConvertible!(Stuff, E)) {
- aa_[*(cast(immutable(E)*)&stuff)] = [];
+ aa_[*(cast(immutable(E)*)&stuff)] = Void.init;
}
///
@@ -49,7 +51,7 @@ final class HashSet(E) {
isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, E)
) {
foreach (e; stuff) {
- aa_[*(cast(immutable(E)*)&e)] = [];
+ aa_[*(cast(immutable(E)*)&e)] = Void.init;
}
}
@@ -115,7 +117,6 @@ final class HashSet(E) {
}
private:
- alias void[0] Void;
Void[immutable(E)] aa_;
}