mirror of https://github.com/apache/activemq.git
nearly building OpenWire.Net; much closer now
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@366723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40280b7d31
commit
10681a29b8
|
@ -73,6 +73,8 @@ namespace OpenWire.Core.Commands
|
||||||
{
|
{
|
||||||
public class ${jclass.simpleName} : $baseClass
|
public class ${jclass.simpleName} : $baseClass
|
||||||
{
|
{
|
||||||
|
public const int ID_${jclass.simpleName} = ${getEnum(jclass)};
|
||||||
|
|
||||||
"""
|
"""
|
||||||
for (property in properties) {
|
for (property in properties) {
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ namespace OpenWire.Core.Commands
|
||||||
|
|
||||||
|
|
||||||
public override int GetCommandType() {
|
public override int GetCommandType() {
|
||||||
return ${getEnum(jclass)};
|
return ID_${jclass.simpleName};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ class GenerateCSharpMarshalling extends OpenWireScript {
|
||||||
println "Generating Java marshalling code to directory ${destDir}"
|
println "Generating Java marshalling code to directory ${destDir}"
|
||||||
|
|
||||||
def buffer = new StringBuffer()
|
def buffer = new StringBuffer()
|
||||||
|
def readMethodBuffer = new StringBuffer()
|
||||||
|
def writeMethodBuffer = new StringBuffer()
|
||||||
|
|
||||||
int counter = 0
|
int counter = 0
|
||||||
Map map = [:]
|
Map map = [:]
|
||||||
|
@ -55,10 +57,34 @@ class GenerateCSharpMarshalling extends OpenWireScript {
|
||||||
def notAbstract = jclass.simpleName != "ActiveMQDestination"
|
def notAbstract = jclass.simpleName != "ActiveMQDestination"
|
||||||
def abstractText = (notAbstract) ? "" : "abstract "
|
def abstractText = (notAbstract) ? "" : "abstract "
|
||||||
|
|
||||||
buffer << """
|
def marshallerType = jclass.simpleName + "Marshaller"
|
||||||
${jclass.simpleName}Marshaller.class
|
def marshallerField = decapitalize(marshallerType)
|
||||||
"""
|
|
||||||
|
|
||||||
|
if (notAbstract) {
|
||||||
|
buffer << """
|
||||||
|
|
||||||
|
private static $marshallerType $marshallerField = new $marshallerType();
|
||||||
|
|
||||||
|
public static $marshallerType $marshallerType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return $marshallerField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
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 |
|
file.withWriter { out |
|
||||||
out << """//
|
out << """//
|
||||||
// Marshalling code for Open Wire Format for ${jclass.simpleName}
|
// Marshalling code for Open Wire Format for ${jclass.simpleName}
|
||||||
|
@ -79,7 +105,7 @@ using OpenWire.Core.IO;
|
||||||
|
|
||||||
namespace OpenWire.Core.IO
|
namespace OpenWire.Core.IO
|
||||||
{
|
{
|
||||||
public ${abstractText}class ${jclass.simpleName}Marshaller : $baseClass
|
public ${abstractText}class $marshallerType : $baseClass
|
||||||
{
|
{
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -120,6 +146,10 @@ namespace OpenWire.Core.IO
|
||||||
out << "dataIn.ReadByte()"
|
out << "dataIn.ReadByte()"
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "byte[]":
|
||||||
|
out << "ReadBytes(dataIn)"
|
||||||
|
break;
|
||||||
|
|
||||||
case "char":
|
case "char":
|
||||||
out << "dataIn.ReadChar()"
|
out << "dataIn.ReadChar()"
|
||||||
break;
|
break;
|
||||||
|
@ -152,8 +182,16 @@ namespace OpenWire.Core.IO
|
||||||
out << "ReadBrokerIds(dataIn)"
|
out << "ReadBrokerIds(dataIn)"
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "BrokerInfo[]":
|
||||||
|
out << "ReadBrokerInfos(dataIn)"
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "DataStructure[]":
|
||||||
|
out << "ReadDataStructures(dataIn)"
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
out << "Read${type}(dataIn)"
|
out << "(${type}) CommandMarshallerRegistry.${type}Marshaller.ReadCommand(dataIn)"
|
||||||
}
|
}
|
||||||
out << """;
|
out << """;
|
||||||
"""
|
"""
|
||||||
|
@ -194,6 +232,10 @@ namespace OpenWire.Core.IO
|
||||||
out << "dataOut.Write($getter);"
|
out << "dataOut.Write($getter);"
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "byte[]":
|
||||||
|
out << "WriteBytes($getter, dataOut);"
|
||||||
|
break;
|
||||||
|
|
||||||
case "char":
|
case "char":
|
||||||
out << "dataOut.Write($getter);"
|
out << "dataOut.Write($getter);"
|
||||||
break;
|
break;
|
||||||
|
@ -223,11 +265,19 @@ namespace OpenWire.Core.IO
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "BrokerId[]":
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
out << "Write${type}($getter, dataOut);"
|
out << "CommandMarshallerRegistry.${type}Marshaller.WriteCommand($getter, dataOut);"
|
||||||
}
|
}
|
||||||
out << """
|
out << """
|
||||||
"""
|
"""
|
||||||
|
@ -240,5 +290,62 @@ namespace OpenWire.Core.IO
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue