You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by gr...@apache.org on 2010/09/22 16:16:17 UTC
svn commit: r999964 - in /incubator/etch/trunk:
binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/
binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/
binding-csharp/compiler/src/main/java/org/apache/etch/bindi...
Author: grandyho
Date: Wed Sep 22 14:16:17 2010
New Revision: 999964
URL: http://svn.apache.org/viewvc?rev=999964&view=rev
Log:
extended all etch compilers to generate configuration files for wireshark
Added:
incubator/etch/trunk/binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/etch_wireshark.vm
incubator/etch/trunk/binding-csharp/compiler/src/main/resources/org/apache/etch/bindings/csharp/compiler/etch_wireshark.vm
incubator/etch/trunk/binding-java/compiler/src/main/resources/org/apache/etch/bindings/java/compiler/etch_wireshark.vm
Modified:
incubator/etch/trunk/binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/Compiler.java
incubator/etch/trunk/binding-csharp/compiler/src/main/java/org/apache/etch/bindings/csharp/compiler/Compiler.java
incubator/etch/trunk/binding-java/compiler/src/main/java/org/apache/etch/bindings/java/compiler/Compiler.java
Modified: incubator/etch/trunk/binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/Compiler.java?rev=999964&r1=999963&r2=999964&view=diff
==============================================================================
--- incubator/etch/trunk/binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-c/compiler/src/main/java/org/apache/etch/bindings/c/compiler/Compiler.java Wed Sep 22 14:16:17 2010
@@ -138,7 +138,7 @@ public class Compiler extends Backend {
impl_h_vm = getTemplate(path, "impl_h.vm");
impl_c_vm = getTemplate(path, "impl_c.vm");
- etch_keywords_vm = getTemplate(path, "etch_keywords.vm");
+ etch_keywords_vm = getTemplate(path, "etch_wireshark.vm");
// Keyword list
local_kwd = getPath(path, "cKeywords.kwd");
@@ -1064,7 +1064,6 @@ public class Compiler extends Backend {
public String getKeywordForWireshark(String fieldname) {
int hash = Hash.hash(fieldname);
return String.format("0x%08x", hash) + "," + fieldname;
-
}
@@ -1134,7 +1133,7 @@ public class Compiler extends Backend {
}
public String getKeywordFilename(Service intf) {
- return getServiceName(intf) + "_keywords_wireshark.txt";
+ return getServiceName(intf) + "_wireshark.ewh";
}
public String getBaseFileNameI(Service intf, String suffix) {
Added: incubator/etch/trunk/binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/etch_wireshark.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/etch_wireshark.vm?rev=999964&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/etch_wireshark.vm (added)
+++ incubator/etch/trunk/binding-c/compiler/src/main/resources/org/apache/etch/bindings/c/compiler/etch_wireshark.vm Wed Sep 22 14:16:17 2010
@@ -0,0 +1,64 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+#foreach($n in $intf.iterator())
+#if($n.isMessage())
+#if(!$n.isHidden())
+#set ( $str="$intf.fqname().$n.name()" )
+$helper.getKeywordForWireshark($str)
+#if(! $n.isOneway())
+#set ( $str="$intf.fqname()._result_$n.name()" )
+$helper.getKeywordForWireshark($str)
+#end
+#end
+#end
+#end
+#foreach($n in $intf.iterator() )
+#if ($n.isStruct() || $n.isEnumx() || $n.isExcept())
+$helper.getKeywordForWireshark($n.fqname().toString())
+#end
+#end
+#set ($tmp = $helper.resetHistory())
+#foreach($n in $intf.iterator())
+#if(!$n.isHidden())
+#if(!$n.isBuiltin())
+#foreach($p in $n.iterator())
+#if(!$helper.historyContains($p.name().toString()))
+$helper.getKeywordForWireshark($p.name().toString())
+#set ($tmp = $helper.addStringToHistory($p.name().toString()))
+#end
+#end
+#end
+#end
+#end
+$helper.getKeywordForWireshark("_Etch_RuntimeException")
+$helper.getKeywordForWireshark("_Etch_AuthException")
+$helper.getKeywordForWireshark("_exception")
+$helper.getKeywordForWireshark("_Etch_List")
+$helper.getKeywordForWireshark("_Etch_Map")
+$helper.getKeywordForWireshark("_Etch_Set")
+$helper.getKeywordForWireshark("_Etch_Datetime")
+$helper.getKeywordForWireshark("msg")
+$helper.getKeywordForWireshark("_messageId")
+$helper.getKeywordForWireshark("_inReplyTo")
+$helper.getKeywordForWireshark("result")
+$helper.getKeywordForWireshark("keys")
+$helper.getKeywordForWireshark("values")
+$helper.getKeywordForWireshark("dateTime")
+$helper.getKeywordForWireshark("keysAndValues")
Modified: incubator/etch/trunk/binding-csharp/compiler/src/main/java/org/apache/etch/bindings/csharp/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/compiler/src/main/java/org/apache/etch/bindings/csharp/compiler/Compiler.java?rev=999964&r1=999963&r2=999964&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/compiler/src/main/java/org/apache/etch/bindings/csharp/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-csharp/compiler/src/main/java/org/apache/etch/bindings/csharp/compiler/Compiler.java Wed Sep 22 14:16:17 2010
@@ -39,6 +39,7 @@ import org.apache.etch.compiler.Output;
import org.apache.etch.compiler.ParseException;
import org.apache.etch.compiler.Token;
import org.apache.etch.compiler.Version;
+import org.apache.etch.compiler.Backend.Gen;
import org.apache.etch.compiler.ast.Builtin;
import org.apache.etch.compiler.ast.Except;
import org.apache.etch.compiler.ast.Item;
@@ -60,6 +61,7 @@ import org.apache.etch.compiler.opt.ToSt
import org.apache.etch.compiler.opt.ToString.FmtItem;
import org.apache.etch.compiler.opt.ToString.StringItem;
import org.apache.etch.util.Assertion;
+import org.apache.etch.util.Hash;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
@@ -105,6 +107,7 @@ public class Compiler extends Backend
impl_vm = getTemplate( path, "impl.vm" );
local_kwd = getPath( path, "csharpKeywords.kwd" );
+ etch_wireshark_vm = getTemplate(path, "etch_wireshark.vm");
}
private final Template vf_vm;
@@ -314,6 +317,8 @@ public class Compiler extends Backend
// Generate readme file.
generateReadme( intf, dir, msgDir );
+
+ generateKeywordList(intf, dir, msgDir, MessageDirection.BOTH, true);
}
// Generate main template file.
@@ -363,6 +368,42 @@ public class Compiler extends Backend
} );
}
+
+ private final Template etch_wireshark_vm;
+
+ private void generateKeywordList(final Service intf, Output dir,
+ final MessageDirection what, final MessageDirection mc,
+ final boolean hasBaseClass) throws Exception {
+ doFile(dir, getKeywordFilename(intf), lh,
+ new Gen() {
+ public void run(PrintWriter pw) throws Exception {
+ generateKeywords(pw, intf, mc, hasBaseClass);
+ }
+ });
+ }
+
+ void generateKeywords(PrintWriter pw, Service intf, MessageDirection mc,
+ boolean hasBaseClass) throws Exception {
+ VelocityContext context = new VelocityContext();
+ context.put("now", new Date());
+ context.put("version", VERSION);
+ context.put("helper", this);
+ context.put("intf", intf);
+ context.put("mc", mc);
+ context.put("suffix", MsgDirHelper.getSuffix(mc).toLowerCase());
+ context.put("hasBaseClass", hasBaseClass);
+ etch_wireshark_vm.merge(context, pw);
+ }
+
+ public String getKeywordForWireshark(String fieldname) {
+ int hash = Hash.hash(fieldname);
+ return String.format("0x%08x", hash) + "," + fieldname;
+ }
+
+ public String getKeywordFilename(Service intf) {
+ return intf.name().name().toLowerCase() + "_wireshark.ewh";
+ }
+
private void generateMain( final Service intf, Output dir,
MessageDirection msgDir ) throws Exception
{
Added: incubator/etch/trunk/binding-csharp/compiler/src/main/resources/org/apache/etch/bindings/csharp/compiler/etch_wireshark.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/compiler/src/main/resources/org/apache/etch/bindings/csharp/compiler/etch_wireshark.vm?rev=999964&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/compiler/src/main/resources/org/apache/etch/bindings/csharp/compiler/etch_wireshark.vm (added)
+++ incubator/etch/trunk/binding-csharp/compiler/src/main/resources/org/apache/etch/bindings/csharp/compiler/etch_wireshark.vm Wed Sep 22 14:16:17 2010
@@ -0,0 +1,64 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+#foreach($n in $intf.iterator())
+#if($n.isMessage())
+#if(!$n.isHidden())
+#set ( $str="$intf.fqname().$n.name()" )
+$helper.getKeywordForWireshark($str)
+#if(! $n.isOneway())
+#set ( $str="$intf.fqname()._result_$n.name()" )
+$helper.getKeywordForWireshark($str)
+#end
+#end
+#end
+#end
+#foreach($n in $intf.iterator() )
+#if ($n.isStruct() || $n.isEnumx() || $n.isExcept())
+$helper.getKeywordForWireshark($n.fqname().toString())
+#end
+#end
+#set ($tmp = $helper.resetHistory())
+#foreach($n in $intf.iterator())
+#if(!$n.isHidden())
+#if(!$n.isBuiltin())
+#foreach($p in $n.iterator())
+#if(!$helper.historyContains($p.name().toString()))
+$helper.getKeywordForWireshark($p.name().toString())
+#set ($tmp = $helper.addStringToHistory($p.name().toString()))
+#end
+#end
+#end
+#end
+#end
+$helper.getKeywordForWireshark("_Etch_RuntimeException")
+$helper.getKeywordForWireshark("_Etch_AuthException")
+$helper.getKeywordForWireshark("_exception")
+$helper.getKeywordForWireshark("_Etch_List")
+$helper.getKeywordForWireshark("_Etch_Map")
+$helper.getKeywordForWireshark("_Etch_Set")
+$helper.getKeywordForWireshark("_Etch_Datetime")
+$helper.getKeywordForWireshark("msg")
+$helper.getKeywordForWireshark("_messageId")
+$helper.getKeywordForWireshark("_inReplyTo")
+$helper.getKeywordForWireshark("result")
+$helper.getKeywordForWireshark("keys")
+$helper.getKeywordForWireshark("values")
+$helper.getKeywordForWireshark("dateTime")
+$helper.getKeywordForWireshark("keysAndValues")
Modified: incubator/etch/trunk/binding-java/compiler/src/main/java/org/apache/etch/bindings/java/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/compiler/src/main/java/org/apache/etch/bindings/java/compiler/Compiler.java?rev=999964&r1=999963&r2=999964&view=diff
==============================================================================
--- incubator/etch/trunk/binding-java/compiler/src/main/java/org/apache/etch/bindings/java/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-java/compiler/src/main/java/org/apache/etch/bindings/java/compiler/Compiler.java Wed Sep 22 14:16:17 2010
@@ -39,6 +39,7 @@ import org.apache.etch.compiler.Output;
import org.apache.etch.compiler.ParseException;
import org.apache.etch.compiler.Token;
import org.apache.etch.compiler.Version;
+import org.apache.etch.compiler.Backend.Gen;
import org.apache.etch.compiler.ast.Builtin;
import org.apache.etch.compiler.ast.Except;
import org.apache.etch.compiler.ast.Item;
@@ -60,6 +61,7 @@ import org.apache.etch.compiler.opt.ToSt
import org.apache.etch.compiler.opt.ToString.FmtItem;
import org.apache.etch.compiler.opt.ToString.StringItem;
import org.apache.etch.util.Assertion;
+import org.apache.etch.util.Hash;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
@@ -106,6 +108,7 @@ public class Compiler extends Backend
impl_vm = getTemplate( path, "impl.vm" );
local_kwd = getPath( path, "javaKeywords.kwd" );
+ etch_wireshark_vm = getTemplate(path, "etch_wireshark.vm");
}
private final Template vf_vm;
@@ -318,6 +321,8 @@ public class Compiler extends Backend
// Generate readme file.
generateReadme( intf, dir, msgDir );
+
+ generateKeywordList(intf, dir, msgDir, MessageDirection.BOTH, true);
}
// Generate main template file.
@@ -343,6 +348,45 @@ public class Compiler extends Backend
} );
}
+
+
+ private final Template etch_wireshark_vm;
+
+ private void generateKeywordList(final Service intf, Output dir,
+ final MessageDirection what, final MessageDirection mc,
+ final boolean hasBaseClass) throws Exception {
+ doFile(dir, getKeywordFilename(intf), lh,
+ new Gen() {
+ public void run(PrintWriter pw) throws Exception {
+ generateKeywords(pw, intf, mc, hasBaseClass);
+ }
+ });
+ }
+
+ void generateKeywords(PrintWriter pw, Service intf, MessageDirection mc,
+ boolean hasBaseClass) throws Exception {
+ VelocityContext context = new VelocityContext();
+ context.put("now", new Date());
+ context.put("version", VERSION);
+ context.put("helper", this);
+ context.put("intf", intf);
+ context.put("mc", mc);
+ context.put("suffix", MsgDirHelper.getSuffix(mc).toLowerCase());
+ context.put("hasBaseClass", hasBaseClass);
+ etch_wireshark_vm.merge(context, pw);
+ }
+
+
+ public String getKeywordForWireshark(String fieldname) {
+ int hash = Hash.hash(fieldname);
+ return String.format("0x%08x", hash) + "," + fieldname;
+ }
+
+ public String getKeywordFilename(Service intf) {
+ return intf.name().name().toLowerCase() + "_wireshark.ewh";
+ }
+
+
private void generateVf( final Service intf, Output dir )
throws Exception
{
Added: incubator/etch/trunk/binding-java/compiler/src/main/resources/org/apache/etch/bindings/java/compiler/etch_wireshark.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/compiler/src/main/resources/org/apache/etch/bindings/java/compiler/etch_wireshark.vm?rev=999964&view=auto
==============================================================================
--- incubator/etch/trunk/binding-java/compiler/src/main/resources/org/apache/etch/bindings/java/compiler/etch_wireshark.vm (added)
+++ incubator/etch/trunk/binding-java/compiler/src/main/resources/org/apache/etch/bindings/java/compiler/etch_wireshark.vm Wed Sep 22 14:16:17 2010
@@ -0,0 +1,64 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+#foreach($n in $intf.iterator())
+#if($n.isMessage())
+#if(!$n.isHidden())
+#set ( $str="$intf.fqname().$n.name()" )
+$helper.getKeywordForWireshark($str)
+#if(! $n.isOneway())
+#set ( $str="$intf.fqname()._result_$n.name()" )
+$helper.getKeywordForWireshark($str)
+#end
+#end
+#end
+#end
+#foreach($n in $intf.iterator() )
+#if ($n.isStruct() || $n.isEnumx() || $n.isExcept())
+$helper.getKeywordForWireshark($n.fqname().toString())
+#end
+#end
+#set ($tmp = $helper.resetHistory())
+#foreach($n in $intf.iterator())
+#if(!$n.isHidden())
+#if(!$n.isBuiltin())
+#foreach($p in $n.iterator())
+#if(!$helper.historyContains($p.name().toString()))
+$helper.getKeywordForWireshark($p.name().toString())
+#set ($tmp = $helper.addStringToHistory($p.name().toString()))
+#end
+#end
+#end
+#end
+#end
+$helper.getKeywordForWireshark("_Etch_RuntimeException")
+$helper.getKeywordForWireshark("_Etch_AuthException")
+$helper.getKeywordForWireshark("_exception")
+$helper.getKeywordForWireshark("_Etch_List")
+$helper.getKeywordForWireshark("_Etch_Map")
+$helper.getKeywordForWireshark("_Etch_Set")
+$helper.getKeywordForWireshark("_Etch_Datetime")
+$helper.getKeywordForWireshark("msg")
+$helper.getKeywordForWireshark("_messageId")
+$helper.getKeywordForWireshark("_inReplyTo")
+$helper.getKeywordForWireshark("result")
+$helper.getKeywordForWireshark("keys")
+$helper.getKeywordForWireshark("values")
+$helper.getKeywordForWireshark("dateTime")
+$helper.getKeywordForWireshark("keysAndValues")