activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r366723 - in /incubator/activemq/trunk/activemq-core/src/gram/script: GenerateCSharpClasses.groovy GenerateCSharpMarshalling.groovy
Date Sat, 07 Jan 2006 13:47:00 GMT
Author: jstrachan
Date: Sat Jan  7 05:46:58 2006
New Revision: 366723

URL: http://svn.apache.org/viewcvs?rev=366723&view=rev
Log:
nearly building OpenWire.Net; much closer now

Modified:
    incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy
    incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy

Modified: incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy?rev=366723&r1=366722&r2=366723&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy (original)
+++ incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy Sat
Jan  7 05:46:58 2006
@@ -73,6 +73,8 @@
 {
     public class ${jclass.simpleName} : $baseClass
     {
+    			public const int ID_${jclass.simpleName} = ${getEnum(jclass)};
+    			
 """
                 for (property in properties) {
 
@@ -91,7 +93,7 @@
 
 
         public override int GetCommandType() {
-            return ${getEnum(jclass)};
+            return ID_${jclass.simpleName};
         }
 
 

Modified: incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy?rev=366723&r1=366722&r2=366723&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
(original)
+++ incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
Sat Jan  7 05:46:58 2006
@@ -34,6 +34,8 @@
         println "Generating Java marshalling code to directory ${destDir}"
 
         def buffer = new StringBuffer()
+        def readMethodBuffer = new StringBuffer()
+        def writeMethodBuffer = new StringBuffer()
 
         int counter = 0
         Map map = [:]
@@ -54,11 +56,35 @@
             
             def notAbstract = jclass.simpleName != "ActiveMQDestination"
             def abstractText = (notAbstract) ? "" : "abstract "
+					
+					 def marshallerType = jclass.simpleName + "Marshaller"
+					 def marshallerField = decapitalize(marshallerType)
+
+					 if (notAbstract) {
+	            buffer << """
+	            
+	      private static $marshallerType $marshallerField = new $marshallerType();
+	      
+        public static $marshallerType $marshallerType
+        {
+            get
+            {
+                return $marshallerField;
+            }
+        }
 
-            buffer << """
-${jclass.simpleName}Marshaller.class
 """
-
+						readMethodBuffer << """
+				case ${jclass.simpleName}.ID_${jclass.simpleName}:
+						return ${marshallerField}.ReadCommand(dataIn);
+						
+"""						
+						writeMethodBuffer << """
+				case ${jclass.simpleName}.ID_${jclass.simpleName}:
+						${marshallerField}.WriteCommand(command, dataOut);
+						
+"""						
+					 }
             file.withWriter { out |
                 out << """//
 // Marshalling code for Open Wire Format for ${jclass.simpleName}
@@ -79,7 +105,7 @@
 
 namespace OpenWire.Core.IO
 {
-    public ${abstractText}class ${jclass.simpleName}Marshaller : $baseClass
+    public ${abstractText}class $marshallerType : $baseClass
     {
 
 """
@@ -120,6 +146,10 @@
                             out << "dataIn.ReadByte()"
                             break;
 
+                        case "byte[]":
+                            out << "ReadBytes(dataIn)"
+                            break;
+
                         case "char":
                             out << "dataIn.ReadChar()"
                             break;
@@ -152,8 +182,16 @@
                             out << "ReadBrokerIds(dataIn)"
                             break;
 
+                        case "BrokerInfo[]":
+                            out << "ReadBrokerInfos(dataIn)"
+                            break;
+
+                        case "DataStructure[]":
+                            out << "ReadDataStructures(dataIn)"
+                            break;
+
                         default:
-                            out << "Read${type}(dataIn)"
+                            out << "(${type}) CommandMarshallerRegistry.${type}Marshaller.ReadCommand(dataIn)"
                     }
                     out << """;
 """
@@ -194,6 +232,10 @@
                             out << "dataOut.Write($getter);"
                             break;
 
+                        case "byte[]":
+                            out << "WriteBytes($getter, dataOut);"
+                            break;
+
                         case "char":
                             out << "dataOut.Write($getter);"
                             break;
@@ -223,11 +265,19 @@
                             break;
 
                         case "BrokerId[]":
-                            out << "dataOut.WriteBrokerIds($getter);"
+                            out << "WriteBrokerIds($getter, dataOut);"
+                            break;
+
+                        case "BrokerInfo[]":
+                            out << "WriteBrokerInfos($getter, dataOut);"
+                            break;
+
+                        case "DataStructure[]":
+                            out << "WriteDataStructures($getter, dataOut);"
                             break;
 
                         default:
-                            out << "Write${type}($getter, dataOut);"
+                            out << "CommandMarshallerRegistry.${type}Marshaller.WriteCommand($getter,
dataOut);"
                     }
                     out << """
 """
@@ -240,5 +290,62 @@
 """
             }
         }
+        
+        def file = new File(destDir, "CommandMarshallerRegistry.cs")
+        file.withWriter { out |
+            out << """//
+// Marshalling code for Open Wire Format for ${jclass.simpleName}
+//
+//
+// NOTE!: This file is autogenerated - do not modify!
+//        if you need to make a change, please see the Groovy scripts in the
+//        activemq-openwire module
+//
+
+using System;
+using System.Collections;
+using System.IO;
+
+using OpenWire.Core;
+using OpenWire.Core.Commands;
+using OpenWire.Core.IO;
+
+namespace OpenWire.Core.IO
+{
+    public class CommandMarshallerRegistry
+    {
+				public static Command ReadCommand(BinaryReader dataIn) 
+				{
+						byte commandID = dataIn.ReadByte();
+						switch (commandID) 
+						{
+$readMethodBuffer						
+								default:
+										throw new Exception("Unknown command type: " + commandID);
+						}
+				}
+
+
+				public static void WriteCommand(Command command, BinaryWriter dataOut) 
+				{
+				    int commandID = command.CommandType;
+						dataOut.Write(commandID);
+						switch (commandID) 
+						{
+$readMethodBuffer						
+								default:
+										throw new Exception("Unknown command type: " + commandID);
+						}
+				}
+
+
+				// Properties     
+$buffer
+		
+    }
+}
+"""
+
+				}		
     }
 }



Mime
View raw message