You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2018/10/29 09:02:23 UTC
[tinkerpop] branch TINKERPOP-2059 updated: gremlin-javascript:
Expose withOptions as an object instance
This is an automated email from the ASF dual-hosted git repository.
jorgebg pushed a commit to branch TINKERPOP-2059
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/TINKERPOP-2059 by this push:
new c797cb5 gremlin-javascript: Expose withOptions as an object instance
c797cb5 is described below
commit c797cb5c79aee85ce2dfd56e83775be736750c65
Author: Jorge Bay Gondra <jo...@gmail.com>
AuthorDate: Mon Oct 29 10:02:16 2018 +0100
gremlin-javascript: Expose withOptions as an object instance
---
gremlin-javascript/glv/TraversalSource.template | 16 ++++-------
.../main/javascript/gremlin-javascript/index.js | 2 +-
.../gremlin-javascript/lib/process/traversal.js | 32 +++++++---------------
3 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 32a69ec..c66cbb4 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -215,13 +215,9 @@ class TraversalSideEffects {
}
-class WithOptions {
- constructor() {
-<% withOptions.each { %>
- this.<%= it.name %> = <%= it.value %>;
-<% } %>
- }
-}
+const withOptions = {
+ <%= withOptions.collect { it.name + ": " + it.value }.join(",\n ")%>
+};
function toEnum(typeName, keys) {
const result = {};
@@ -250,13 +246,11 @@ module.exports = {
EnumValue,
P,
TextP,
- WithOptions,
+ withOptions,
IO,
Traversal,
TraversalSideEffects,
- Traverser,
- withOptions: WithOptions,
- //withOptions: toEnum('WithOptions', '<%= withOptions.collect {it.name}.join(' ') %>')<%
+ Traverser<%
enums.each{ enumClass ->
out.print ",\n " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" +
enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')"
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index 6cc4004..b9bacc0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -72,7 +72,7 @@ module.exports = {
GraphTraversalSource: gt.GraphTraversalSource,
statics: gt.statics,
Translator: Translator,
- WithOptions: t.withOptions
+ withOptions: t.withOptions
},
structure: {
io: {
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 54bed4e..ddf58b0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -388,25 +388,15 @@ class TraversalSideEffects {
}
-class WithOptions {
- constructor() {
-
- this.tokens = "~tinkerpop.valueMap.tokens";
-
- this.none = 0;
-
- this.ids = 1;
-
- this.labels = 2;
-
- this.keys = 4;
-
- this.values = 8;
-
- this.all = 15;
-
- }
-}
+const withOptions = {
+ tokens: "~tinkerpop.valueMap.tokens",
+ none: 0,
+ ids: 1,
+ labels: 2,
+ keys: 4,
+ values: 8,
+ all: 15
+};
function toEnum(typeName, keys) {
const result = {};
@@ -435,13 +425,11 @@ module.exports = {
EnumValue,
P,
TextP,
- WithOptions,
+ withOptions,
IO,
Traversal,
TraversalSideEffects,
Traverser,
- withOptions: WithOptions,
- //withOptions: toEnum('WithOptions', 'tokens none ids labels keys values all'),
barrier: toEnum('Barrier', 'normSack'),
cardinality: toEnum('Cardinality', 'list set single'),
column: toEnum('Column', 'keys values'),