tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From florianhockm...@apache.org
Subject [6/9] tinkerpop git commit: Fix generation of methods with equal signatures
Date Sun, 03 Sep 2017 16:19:44 GMT
Fix generation of methods with equal signatures

Now only one method with the same name and combination of parameter names is allowed. This
solves the problem where different parameter combinations in Java lead to the same combination
in C# as their types have no equivalent and thus object is used instead.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d4fb8888
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d4fb8888
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d4fb8888

Branch: refs/heads/TINKERPOP-1752
Commit: d4fb888802a1fdac33d4f57e559c82e821d24151
Parents: 2f1920f
Author: florianhockmann <florianhockmann@apache.org>
Authored: Sun Sep 3 16:39:20 2017 +0200
Committer: florianhockmann <florianhockmann@apache.org>
Committed: Sun Sep 3 16:39:20 2017 +0200

----------------------------------------------------------------------
 gremlin-dotnet/pom.xml                          | 20 ++++---
 .../Process/Traversal/GraphTraversal.cs         | 10 ----
 .../Process/Traversal/GraphTraversalSource.cs   | 63 --------------------
 3 files changed, 13 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d4fb8888/gremlin-dotnet/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml
index 5ead0a8..816ca09 100644
--- a/gremlin-dotnet/pom.xml
+++ b/gremlin-dotnet/pom.xml
@@ -177,18 +177,20 @@ def toCSharpParamString = { param ->
     }
 
 def getJavaParamTypeString = { method ->
-    def parameters = method.parameters;
-    if (parameters.length == 0)
-        return ""
-    return parameters.collect { param ->
-                        param.type.simpleName
-                    }.join(",")
+    getJavaParameterTypeNames(method).join(",")
+}
+
+def getCSharpParamTypeString = { method ->
+    return method.parameters.
+            collect { param ->
+                toCSharpType(param.type.simpleName)
+            }.join(",")
 }
 
 def getCSharpParamString = { method ->
     def parameters = method.parameters;
     if (parameters.length == 0)
-        return ""
+        return ""        
     def csharpParameters = parameters.
             init().
             collect { param ->
@@ -260,6 +262,7 @@ def binding = ["pmethods": P.class.getMethods().
                                                     !it.name.equals(TraversalSource.Symbols.withComputer)
                                         }.
                                         sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a)
<=> getJavaParamTypeString(b) }.
+                                        unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a)
<=> getCSharpParamTypeString(b) }.
                                         collect { javaMethod ->
                                             def parameters = getCSharpParamString(javaMethod)
                                             def paramNames = getParamNames(javaMethod.parameters).join(",
")
@@ -268,6 +271,7 @@ def binding = ["pmethods": P.class.getMethods().
                "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
                                         findAll { GraphTraversal.class.equals(it.returnType)
&& !it.name.equals('inject')}.                                                   
                          
                                         sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a)
<=> getJavaParamTypeString(b) }.
+                                        unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a)
<=> getCSharpParamTypeString(b) }.
                                         collect { javaMethod ->
                                             def typeArguments = javaMethod.genericReturnType.actualTypeArguments.collect{t
-> ((java.lang.Class)t).simpleName}
                                             def parameters = getCSharpParamString(javaMethod)
@@ -278,6 +282,7 @@ def binding = ["pmethods": P.class.getMethods().
                                         findAll { GraphTraversal.class.equals(it.returnType)
}.
                                         findAll { !it.name.equals("clone") && !it.name.equals("iterate")
}.
                                         sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a)
<=> getJavaParamTypeString(b) }.
+                                        unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a)
<=> getCSharpParamTypeString(b) }.
                                         collect { javaMethod ->
                                             def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod)
                                             def t1 = toCSharpType(typeNames[0])
@@ -292,6 +297,7 @@ def binding = ["pmethods": P.class.getMethods().
                                         findAll { Modifier.isStatic(it.getModifiers()) }.
                                         findAll { !it.name.equals("__") && !it.name.equals("start")
}.
                                         sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a)
<=> getJavaParamTypeString(b) }.
+                                        unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a)
<=> getCSharpParamTypeString(b) }.
                                         collect { javaMethod ->
                                             def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod)
                                             def t2 = toCSharpType(typeNames[1])

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d4fb8888/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index b702069..cd5a9b7 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -275,16 +275,6 @@ namespace Gremlin.Net.Process.Traversal
         /// <summary>
         ///     Adds the by step to this <see cref="GraphTraversal{SType, EType}" />.
         /// </summary>
-        public GraphTraversal< S , E > By (object function)
-        {
-            var args = new List<object> { function };
-            Bytecode.AddStep("by", args);
-            return Wrap< S , E >(this);
-        }
-
-        /// <summary>
-        ///     Adds the by step to this <see cref="GraphTraversal{SType, EType}" />.
-        /// </summary>
         public GraphTraversal< S , E > By (object function, object comparator)
         {
             var args = new List<object> { function, comparator };

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d4fb8888/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 27e0e73..6819298 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -108,15 +108,6 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { initialValue, splitOperator };
-            source.Bytecode.AddSource("withSack", args);
-            return source;
-        }
-
         public GraphTraversalSource WithSack(object initialValue, object splitOperator, object
mergeOperator)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
@@ -126,60 +117,6 @@ namespace Gremlin.Net.Process.Traversal
             return source;
         }
 
-        public GraphTraversalSource WithSack(object initialValue)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { initialValue };
-            source.Bytecode.AddSource("withSack", args);
-            return source;
-        }
-
-        public GraphTraversalSource WithSack(object initialValue, object mergeOperator)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { initialValue, mergeOperator };
-            source.Bytecode.AddSource("withSack", args);
-            return source;
-        }
-
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { initialValue, splitOperator };
-            source.Bytecode.AddSource("withSack", args);
-            return source;
-        }
-
-        public GraphTraversalSource WithSack(object initialValue, object splitOperator, object
mergeOperator)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { initialValue, splitOperator, mergeOperator
};
-            source.Bytecode.AddSource("withSack", args);
-            return source;
-        }
-
-        public GraphTraversalSource WithSideEffect(string key, object initialValue)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { key, initialValue };
-            source.Bytecode.AddSource("withSideEffect", args);
-            return source;
-        }
-
-        public GraphTraversalSource WithSideEffect(string key, object initialValue, object
reducer)
-        {
-            var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),
-                                                  new Bytecode(Bytecode));
-            var args = new List<object> { key, initialValue, reducer };
-            source.Bytecode.AddSource("withSideEffect", args);
-            return source;
-        }
-
         public GraphTraversalSource WithSideEffect(string key, object initialValue)
         {
             var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies),


Mime
View raw message