Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 74332 invoked from network); 28 Jul 2009 13:36:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 13:36:56 -0000 Received: (qmail 76060 invoked by uid 500); 28 Jul 2009 13:38:13 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 76005 invoked by uid 500); 28 Jul 2009 13:38:13 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 75996 invoked by uid 99); 28 Jul 2009 13:38:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 13:38:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 13:38:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 987C523888C5; Tue, 28 Jul 2009 13:37:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798517 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/activemq/ src/main/java/org/apache/activemq/nms/ src/main/... Date: Tue, 28 Jul 2009 13:37:49 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090728133749.987C523888C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Tue Jul 28 13:37:48 2009 New Revision: 798517 URL: http://svn.apache.org/viewvc?rev=798517&view=rev Log: Populate with the initial generators work, not complete. Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java (with props) activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/resources/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/test/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/test/java/ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/test/resources/ Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml Tue Jul 28 13:37:48 2009 @@ -0,0 +1,137 @@ + + + + + + + + org.apache + apache + 6 + + + 4.0.0 + org.apache.activemq + nms-activemq-openwire-generator + 0.0.1-SNAPSHOT + NMS.ActiveMQ Openwire Protocol Generator + Tool used to create the NMS.ActiveMQ OpenWire Commands and Marshallers. + 2009 + + 2.0.9 + + + + Apache Software Foundation + http://www.apache.org/ + + + http://activemq.apache.org/cms + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Development List + dev-subscribe@activemq.apache.org + dev-unsubscribe@activemq.apache.org + dev@activemq.apache.org + + + + + 5.3-SNAPSHOT + Apache NMS.ActiveMQ + 0.1.0 + 1.6.2 + 1.3.1 + ${ACTIVEMQ_SRC_HOME}/activemq-core/ + + + + + org.apache.activemq + activemq-openwire-generator + ${activemq-version} + + + org.apache.activemq + activemq-core + ${activemq-version} + + + + + + release.apache.org + ActiveMQ-CPP Release Repository + file:///home/tabish/dev/maven2/repo/release + + + snapshots.apache.org + ActiveMQ-CPP Snapshots Repository + file:///home/tabish/dev/maven2/repo/snapshots + + + + + scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.OpenWire.Tool + scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.OpenWire.Tool + http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.OpenWire.Tool + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.1 + + + org.codehaus.mojo + rat-maven-plugin + 1.0-alpha-3 + + + + + + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,145 @@ +/** + * + * 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. + */ +package org.apache.activemq.nms.openwire.tool; + +import java.io.File; + +import org.apache.activemq.nms.openwire.tool.commands.CommandGenerator; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.codehaus.jam.JamService; +import org.codehaus.jam.JamServiceFactory; +import org.codehaus.jam.JamServiceParams; + +public class AmqCSharpGeneratorTask extends Task { + + int maxVersion = 3; + File source = new File("."); + File target = new File("."); + + public static void main(String[] args) { + + Project project = new Project(); + project.init(); + AmqCSharpGeneratorTask generator = new AmqCSharpGeneratorTask(); + generator.setProject(project); + + if (args.length > 0) { + generator.maxVersion = Integer.parseInt(args[0]); + System.out.println("Generator Max Version: " + + Integer.parseInt(args[0])); + } + + if (args.length > 1) { + generator.source = new File(args[1]); + System.out.println("Generator Source: " + generator.source); + } + + if (args.length > 2) { + generator.target = new File(args[2]); + System.out.println("Generator Source: " + generator.target); + } + + generator.execute(); + } + + public void execute() throws BuildException { + try { + + String sourceDir = source + "/src/main/java"; + + System.out.println("Parsing source files in: " + sourceDir); + + JamServiceFactory jamServiceFactory = JamServiceFactory + .getInstance(); + JamServiceParams params = jamServiceFactory.createServiceParams(); + File[] dirs = new File[] { new File(sourceDir) }; + params.includeSourcePattern(dirs, "**/*.java"); + JamService jam = jamServiceFactory.createService(params); + + { + CommandGenerator script = new CommandGenerator(); + script.setJam(jam); + script.setTargetDir(target + "/src/main"); + script.setOpenwireVersion(maxVersion); + script.run(); + } + +// for (int i = 1; i <= maxVersion; ++i) { +// +// { +// AmqCppMarshallingHeadersGenerator script = new AmqCppMarshallingHeadersGenerator(); +// script.setJam(jam); +// script.setTargetDir(target + "/src/main"); +// script.setOpenwireVersion(i); +// script.run(); +// } +// { +// AmqCppMarshallingClassesGenerator script = new AmqCppMarshallingClassesGenerator(); +// script.setJam(jam); +// script.setTargetDir(target + "/src/main"); +// script.setOpenwireVersion(i); +// script.run(); +// } +// { +// AmqCppTestMarshallingHeadersGenerator script = new AmqCppTestMarshallingHeadersGenerator(); +// script.setJam(jam); +// script.setTargetDir(target + "/src/test"); +// script.setOpenwireVersion(i); +// script.run(); +// } +// { +// AmqCppTestMarshallingClassesGenerator script = new AmqCppTestMarshallingClassesGenerator(); +// script.setJam(jam); +// script.setTargetDir(target + "/src/test"); +// script.setOpenwireVersion(i); +// script.run(); +// } +// } + + } catch (Exception e) { + throw new BuildException(e); + } + } + + public int getMaxVersion() { + return maxVersion; + } + + public void setMaxVersion(int version) { + this.maxVersion = version; + } + + public File getSource() { + return source; + } + + public void setSource(File basedir) { + this.source = basedir; + } + + public File getTarget() { + return target; + } + + public void setTarget(File target) { + this.target = target; + } + +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/AmqCSharpGeneratorTask.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,293 @@ +/** + * 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. + */ +package org.apache.activemq.nms.openwire.tool.commands; + +import java.io.PrintWriter; +import java.util.Set; + +import org.codehaus.jam.JProperty; + +public class CommandClassGenerator extends CommandCodeGenerator { + + public void generate( PrintWriter out ) { + + // Start with the license. + generateLicence(out); + + out.println("#ifndef _ACTIVEMQ_COMMANDS_"+getClassName().toUpperCase()+"_H_"); + out.println("#define _ACTIVEMQ_COMMANDS_"+getClassName().toUpperCase()+"_H_"); + out.println(""); + out.println("// Turn off warning message for ignored exception specification"); + out.println("#ifdef _MSC_VER"); + out.println("#pragma warning( disable : 4290 )"); + out.println("#endif"); + out.println(""); + + populateIncludeFilesSet(); + for( String include : getIncludeFiles() ) { + if( include != null ) { + out.println("#include "+include); + } + } + + out.println(""); + generateNamespaceWrapper( out ); + generateForwardDeclarations( out ); + + out.println(" using decaf::lang::Pointer;"); + out.println(""); + out.println(" /*"); + out.println(" *"); + out.println(" * Command code for OpenWire format for "+getClassName() ); + out.println(" *"); + out.println(" * NOTE!: This file is auto generated - do not modify!"); + out.println(" * if you need to make a change, please see the Java Classes"); + out.println(" * in the activemq-cpp-openwire-generator module"); + out.println(" *"); + out.println(" */"); + + generateClassDefinition( out ); + generateProperties( out ); + + if( !isAssignable() ) { + out.println(" protected:"); + out.println(""); + out.println(" "+getClassName()+"( const "+getClassName()+"& ) : " + getBaseClassName() + "() {};"); + out.println(" "+getClassName()+"& operator= ( const "+getClassName()+"& ) { return *this; };"); + out.println(""); + } + + out.println(" public:"); + out.println(""); + out.println(" "+getClassName()+"();"); + out.println(""); + + if( isAssignable() ) { + out.println(" "+getClassName()+"( const "+getClassName()+"& other );"); + out.println(""); + } + + generateAdditionalConstructors( out ); + + out.println(" virtual ~"+getClassName()+"();"); + out.println(""); + out.println(" /**"); + out.println(" * Get the unique identifier that this object and its own"); + out.println(" * Marshaler share."); + out.println(" * @returns new DataStructure type copy."); + out.println(" */"); + out.println(" virtual unsigned char getDataStructureType() const;"); + out.println(""); + out.println(" /**"); + out.println(" * Clone this object and return a new instance that the"); + out.println(" * caller now owns, this will be an exact copy of this one"); + out.println(" * @returns new copy of this object."); + out.println(" */"); + out.println(" virtual "+getClassName()+"* cloneDataStructure() const;"); + out.println(""); + out.println(" /**"); + out.println(" * Copy the contents of the passed object into this object's"); + out.println(" * members, overwriting any existing data."); + out.println(" * @param src - Source Object"); + out.println(" */"); + out.println(" virtual void copyDataStructure( const DataStructure* src );"); + out.println(""); + out.println(" /**"); + out.println(" * Returns a string containing the information for this DataStructure"); + out.println(" * such as its type and value of its elements."); + out.println(" * @return formatted string useful for debugging."); + out.println(" */"); + out.println(" virtual std::string toString() const;"); + out.println(""); + out.println(" /**" ); + out.println(" * Compares the DataStructure passed in to this one, and returns if" ); + out.println(" * they are equivalent. Equivalent here means that they are of the" ); + out.println(" * same type, and that each element of the objects are the same." ); + out.println(" * @returns true if DataStructure's are Equal." ); + out.println(" */" ); + out.println(" virtual bool equals( const DataStructure* value ) const;" ); + out.println(""); + + generateAdditonalMembers( out ); + generatePropertyAccessors( out ); + + if( isComparable() ) { + out.println(" virtual int compareTo( const "+getClassName()+"& value ) const;"); + out.println(""); + out.println(" virtual bool equals( const "+getClassName()+"& value ) const;"); + out.println(""); + out.println(" virtual bool operator==( const "+getClassName()+"& value ) const;"); + out.println(""); + out.println(" virtual bool operator<( const "+getClassName()+"& value ) const;"); + out.println(""); + } + + if( isAssignable() ) { + out.println(" "+getClassName()+"& operator= ( const "+getClassName()+"& other );"); + out.println(""); + } + + if( isGenIsClass() ) { + out.println(" /**"); + out.println(" * @return an answer of true to the is"+getClassName()+"() query."); + out.println(" */"); + out.println(" virtual bool is"+getClassName()+"() const {"); + out.println(" return true;"); + out.println(" }"); + out.println(""); + } + + if( getBaseClassName().equals( "BaseCommand" ) ) { + out.println(" /**" ); + out.println(" * Allows a Visitor to visit this command and return a response to the" ); + out.println(" * command based on the command type being visited. The command will call" ); + out.println(" * the proper processXXX method in the visitor." ); + out.println(" * " ); + out.println(" * @return a Response to the visitor being called or NULL if no response." ); + out.println(" */" ); + out.println(" virtual Pointer visit( activemq::state::CommandVisitor* visitor )" ); + out.println(" throw( exceptions::ActiveMQException );" ); + out.println(""); + } + + out.println(" };"); + out.println(""); + out.println("}}"); + out.println(""); + out.println("#endif /*_ACTIVEMQ_COMMANDS_"+getClassName().toUpperCase()+"_H_*/"); + } + + protected void populateIncludeFilesSet() { + + Set includes = getIncludeFiles(); + + includes.add(""); + includes.add(""); + includes.add(""); + includes.add(""); + includes.add(""); + + if( isComparable() ) { + includes.add(""); + } + + for( JProperty property : getProperties() ) { + if( !property.getType().isPrimitiveType() && + !property.getType().getSimpleName().equals("String") && + !property.getType().getSimpleName().equals("ByteSequence") ) + { + + if( toHeaderFileName( property.getType() ) != null ) { + includes.add( + ""); + } + } + } + } + + protected void generateNamespaceWrapper( PrintWriter out ) { + out.println("namespace activemq{"); + out.println("namespace commands{"); + out.println(""); + } + + protected void generateForwardDeclarations( PrintWriter out ) { + } + + protected void generateClassDefinition( PrintWriter out ) { + out.print(" class AMQCPP_API "+getClassName()+" : " ); + + if( isComparable() ) { + out.println("public "+ getBaseClassName() +", public decaf::lang::Comparable<"+getClassName()+"> {" ); + } else { + out.print("public "+ getBaseClassName() +" {" ); + out.println(""); + } + } + + protected void generateProperties( PrintWriter out ) { + out.println(" protected:"); + out.println(""); + + for( JProperty property : getProperties() ) { + String type = toCppType(property.getType()); + String name = decapitalize(property.getSimpleName()); + + if( !property.getType().isPrimitiveType() && + !property.getType().getSimpleName().equals("ByteSequence") && + !property.getType().getSimpleName().equals("String") && + !type.startsWith("std::vector") ) { + + type = "Pointer<" + type + ">"; + } + + out.println(" "+type+" "+name+";"); + } + + out.println(""); + out.println(" public:"); + out.println(""); + out.println(" const static unsigned char ID_"+ + getClassName().toUpperCase()+" = "+getOpenWireOpCode()+";"); + out.println(""); + if( isComparable() ) { + out.println(" typedef decaf::lang::PointerComparator<"+getClassName()+"> COMPARATOR;"); + out.println(""); + } + } + + protected void generateAdditionalConstructors( PrintWriter out ) { + } + + protected void generateAdditonalMembers( PrintWriter out ) { + } + + protected void generatePropertyAccessors( PrintWriter out ) { + + for( JProperty property : getProperties() ) { + String type = toCppType(property.getType()); + String propertyName = property.getSimpleName(); + String parameterName = decapitalize(propertyName); + String constness = ""; + + if( !property.getType().isPrimitiveType() && + !property.getType().getSimpleName().equals("ByteSequence") && + !property.getType().getSimpleName().equals("String") && + !type.startsWith("std::vector") ) { + + type = "Pointer<" + type + ">&"; + constness = "const "; + } else if( property.getType().getSimpleName().equals("String") || + type.startsWith("std::vector") ) { + + type = type + "&"; + constness = "const "; + } + + if( property.getType().isPrimitiveType() ) { + out.println(" virtual "+type+" "+property.getGetter().getSimpleName()+"() const;"); + } else { + out.println(" virtual const "+type+" "+property.getGetter().getSimpleName()+"() const;"); + out.println(" virtual "+type+" "+property.getGetter().getSimpleName()+"();"); + } + + out.println(" virtual void "+property.getSetter().getSimpleName()+"( "+constness+type+" "+parameterName+" );"); + out.println(""); + } + } + +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,238 @@ +/** + * 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. + */ +package org.apache.activemq.nms.openwire.tool.commands; + +import java.io.PrintWriter; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.codehaus.jam.JClass; +import org.codehaus.jam.JProperty; + +public abstract class CommandCodeGenerator { + + private JClass jClass; + private List properties; + private boolean marshalAware = false; + private String className; + private String baseClassName; + private Set includeFiles = new TreeSet(); + private String openWireOpCode; + private boolean comparable = false; + private boolean assignable = false; + private boolean genIsClass = false; + + public abstract void generate( PrintWriter out ); + + protected void generateLicence(PrintWriter out) { + out.println("/*"); + out.println(" * Licensed to the Apache Software Foundation (ASF) under one or more"); + out.println(" * contributor license agreements. See the NOTICE file distributed with"); + out.println(" * this work for additional information regarding copyright ownership."); + out.println(" * The ASF licenses this file to You under the Apache License, Version 2.0"); + out.println(" * (the \"License\"); you may not use this file except in compliance with"); + out.println(" * the License. You may obtain a copy of the License at"); + out.println(" *"); + out.println(" * http://www.apache.org/licenses/LICENSE-2.0"); + out.println(" *"); + out.println(" * Unless required by applicable law or agreed to in writing, software"); + out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,"); + out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."); + out.println(" * See the License for the specific language governing permissions and"); + out.println(" * limitations under the License."); + out.println(" */"); + out.println(""); + } + + public boolean isGenIsClass() { + return genIsClass; + } + + public void setGenIsClass(boolean genIsClass) { + this.genIsClass = genIsClass; + } + + public boolean isComparable() { + return comparable; + } + + public void setComparable(boolean comparable) { + this.comparable = comparable; + } + + public boolean isAssignable() { + return assignable; + } + + public void setAssignable(boolean assignable) { + this.assignable = assignable; + } + + public JClass getJClass() { + return jClass; + } + + public void setJClass(JClass jClass) { + this.jClass = jClass; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public boolean isMarshalAware() { + return marshalAware; + } + + public void setMarshalAware(boolean marshalAware) { + this.marshalAware = marshalAware; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getBaseClassName() { + return baseClassName; + } + + public void setBaseClassName(String baseClassName) { + this.baseClassName = baseClassName; + } + + public Set getIncludeFiles() { + return includeFiles; + } + + public void setIncludeFiles(Set includeFiles) { + this.includeFiles = includeFiles; + } + + public String getOpenWireOpCode() { + return openWireOpCode; + } + + public void setOpenWireOpCode(String openWireOpCode) { + this.openWireOpCode = openWireOpCode; + } + + protected String toHeaderFileName( JClass type ) { + String name = type.getSimpleName(); + + if( name.equals( "String" ) ) { + return null; + } else if( type.isArrayType() ) { + JClass arrayClass = type.getArrayComponentType(); + return toHeaderFileName( arrayClass ); + } else if( name.equals( "Throwable" ) || name.equals( "Exception" ) ) { + return "BrokerError"; + } else if( name.equals("BaseDataStructure" ) ){ + return "DataStructure"; + } else if( name.equals("ByteSequence") ) { + return "std::vector"; + } else if( !type.isPrimitiveType() ) { + return name; + } else { + return null; + } + } + + protected String toCppType(JClass type) { + String name = type.getSimpleName(); + if (name.equals("String")) { + return "std::string"; + } + else if( type.isArrayType() ) { + if( name.equals( "byte[]" ) ) + name = "unsigned char[]"; + + JClass arrayClass = type.getArrayComponentType(); + + if( arrayClass.isPrimitiveType() ) { + return "std::vector<" + name.substring( 0, name.length()-2 ) + ">"; + } else { + return "std::vector< decaf::lang::Pointer<" + + name.substring( 0, name.length()-2 ) + "> >"; + } + } + else if( name.equals( "Throwable" ) || name.equals( "Exception" ) ) { + return "BrokerError"; + } + else if( name.equals("BaseDataStructure" ) ){ + return "DataStructure"; + } + else if( name.equals("ByteSequence") ) { + return "std::vector"; + } + else if( name.equals("boolean") ) { + return "bool"; + } + else if( name.equals("long") ) { + return "long long"; + } + else if( name.equals("byte") ) { + return "unsigned char"; + } + else if( !type.isPrimitiveType() ) { + return name; + } + else { + return name; + } + } + + /** + * Converts the Java type to a C++ default value + */ + protected String toCppDefaultValue(JClass type) { + String name = type.getSimpleName(); + + if (name.equals("boolean")) { + return "false"; + } else if( name.equals("String") ) { + return "\"\""; + } else if( !type.isPrimitiveType() ) { + return "NULL"; + } else { + return "0"; + } + } + + protected String decapitalize(String text) { + if (text == null) { + return null; + } + return text.substring(0, 1).toLowerCase() + text.substring(1); + } + + protected String capitalize(String text) { + if (text == null) { + return null; + } + return text.substring(0, 1).toUpperCase() + text.substring(1); + } + +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,98 @@ +/** + * 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. + */ +package org.apache.activemq.nms.openwire.tool.commands; + +import java.util.HashSet; +import java.util.Set; + +/** + * Provides methods to get a Source file and Header file Code generator given a Class + * name. + * + * @since 2.0 + */ +public class CommandCodeGeneratorsFactory { + + private Set commandsWithShortcuts; + + /* + * Here we store all Commands that need to have a isXXX method generated + * such as isMessage. We then check in the checkNeedsShortcut + * method and if the Command being generated is in this list we create a + * method call to override the virtual method in the base Command interface. + */ + { + commandsWithShortcuts = new HashSet(); + commandsWithShortcuts.add( "Response" ); + commandsWithShortcuts.add( "RemoveInfo" ); + commandsWithShortcuts.add( "MessageDispatch" ); + commandsWithShortcuts.add( "BrokerInfo" ); + commandsWithShortcuts.add( "KeepAliveInfo" ); + commandsWithShortcuts.add( "WireFormatInfo" ); + commandsWithShortcuts.add( "Message" ); + commandsWithShortcuts.add( "MessageAck" ); + commandsWithShortcuts.add( "ProducerAck" ); + commandsWithShortcuts.add( "ProducerInfo" ); + commandsWithShortcuts.add( "MessageDispatchNotification" ); + commandsWithShortcuts.add( "ShutdownInfo" ); + commandsWithShortcuts.add( "TransactionInfo" ); + commandsWithShortcuts.add( "ConnectionInfo" ); + commandsWithShortcuts.add( "ConsumerInfo" ); + commandsWithShortcuts.add( "RemoveSubscriptionInfo" ); + + } + + /** + * Given a class name return an instance of a CSharp Class File Generator + * that can generate the file for the Class. + * + * @param className - name of the class to find the generator for + * + * @return a new Header File code generator. + */ + public CommandCodeGenerator getCodeGenerator( String className ) { + + CommandCodeGenerator generator = null; +// if( className.equals("Message") ) { +// generator = new MessageHeaderGenerator(); +// } else if( className.equals("ConnectionId") ) { +// generator = new ConnectionIdHeaderGenerator(); +// } else if( className.equals("ConsumerId") ) { +// generator = new ConsumerIdHeaderGenerator(); +// } else if( className.equals("ProducerId") ) { +// generator = new ProducerIdHeaderGenerator(); +// } else if( className.equals("SessionId") ) { +// generator = new SessionIdHeaderGenerator(); +// } else if( className.equals("SessionInfo") ) { +// generator = new SessionInfoHeaderGenerator(); +// } else { + generator = new CommandClassGenerator(); +// } + + if( className.endsWith("Id") ) { + generator.setComparable( true ); + generator.setAssignable( true ); + } + + if( this.commandsWithShortcuts.contains( className ) ) { + generator.setGenIsClass( true ); + } + + return generator; + } + +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandCodeGeneratorsFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,118 @@ +/** + * 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. + */ +package org.apache.activemq.nms.openwire.tool.commands; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; + +import org.apache.activemq.openwire.tool.MultiSourceGenerator; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.FixCRLF; +import org.codehaus.jam.JClass; + +/** + * + * @version $Revision: 409828 $ + */ +public class CommandGenerator extends MultiSourceGenerator { + + private CommandCodeGeneratorsFactory generatorsFactory = + new CommandCodeGeneratorsFactory(); + + protected String targetDir="./src/main"; + + public String getTargetDir() { + return targetDir; + } + + public void setTargetDir(String targetDir) { + this.targetDir = targetDir; + } + + protected void processClass(JClass jclass) { + + // Prepare the State variables for the current class + simpleName = jclass.getSimpleName(); + superclass = jclass.getSuperclass(); + className = getClassName(jclass); + baseClass = getBaseClassName(jclass); + + System.out.println(getClass().getName() + " processing class: " + simpleName); + + try { + // Using the current JClass state in the MultiSourceGenerator we can + // now generate the Header and Source for the CSharp commands. + generateClassFile(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public Object run() { + filePostFix = ".cpp"; + if (destDir == null) { + destDir = new File( + targetDir+"/activemq/commands"); + } + + return super.run(); + } + + protected void generateClassFile() throws Exception { + + File headerFile = new File(destDir, className + ".cs"); + + CommandCodeGenerator generator = generatorsFactory.getCodeGenerator( className ); + + generator.setJClass( getJclass() ); + generator.setProperties( getProperties() ); + generator.setMarshalAware( isMarshallerAware() ); + generator.setClassName( getClassName() ); + generator.setBaseClassName( getBaseClass() ); + generator.setOpenWireOpCode( getOpenWireOpCode(getJclass()) ); + + PrintWriter out = null; + try { + out = new PrintWriter(new FileWriter(headerFile)); + generator.generate(out); + } catch( Exception e ) { + throw new RuntimeException(e); + } finally { + if( out != null ) { + out.close(); + } + } + + // Use the FixCRLF Ant Task to make sure the file has consistent + // newlines + // so that SVN does not complain on checkin. + Project project = new Project(); + project.init(); + FixCRLF fixCRLF = new FixCRLF(); + fixCRLF.setProject(project); + fixCRLF.setSrcdir(headerFile.getParentFile()); + fixCRLF.setIncludes(headerFile.getName()); + fixCRLF.execute(); + } + + @Override + protected void generateFile(PrintWriter arg0) throws Exception { + // Not used here since we override the process method. + } + +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java?rev=798517&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java (added) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java Tue Jul 28 13:37:48 2009 @@ -0,0 +1,434 @@ +/** + * + * 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. + */ +package org.apache.activemq.nms.openwire.tool.marshalers; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +import org.apache.activemq.openwire.tool.MultiSourceGenerator; +import org.codehaus.jam.JAnnotation; +import org.codehaus.jam.JAnnotationValue; +import org.codehaus.jam.JClass; +import org.codehaus.jam.JProperty; + +/** + * + * @version $Revision: 381410 $ + */ +public class AmqCSharpMarshallersGenerator extends MultiSourceGenerator { + + protected String targetDir="./src/main"; + protected List concreteClasses = new ArrayList(); + protected File factoryFile; + protected String factoryFileName = "MarshallerFactory"; + protected String indent = " "; + + /** + * Overrides the base class init since we don't mark any marshaller classes as + * being manually maintained. + */ + protected void initialiseManuallyMaintainedClasses() { + } + + /** + * Returns all the valid properties available on the current class. Overrides the + * method in {@link MultiSourceGenerator} to add filtering on the Openwire Version + * number so that we can rerun this tool for older versions and produce an exact + * match to what was previously generated. + * + * @return List of Properties valid for the current {@link JClass} and Openwire version. + */ + public List getProperties() { + List answer = new ArrayList(); + JProperty[] properties = jclass.getDeclaredProperties(); + for (int i = 0; i < properties.length; i++) { + JProperty property = properties[i]; + if (isValidProperty(property)) { + + JAnnotation annotation = property.getAnnotation("openwire:property"); + JAnnotationValue version = annotation.getValue("version"); + + if( version.asInt() <= this.getOpenwireVersion() ) { + answer.add(property); + } + } + } + return answer; + } + + public Object run() { + filePostFix = getFilePostFix(); + if (destDir == null) { + destDir = new File(targetDir+"/activemq/wireformat/openwire/marshal/v"+getOpenwireVersion()); + } + Object answer = super.run(); + processFactory(); + return answer; + } + + protected void processClass(JClass jclass) { + super.processClass(jclass); + + if (!jclass.isAbstract()) { + concreteClasses.add(jclass); + } + } + + protected String getClassName(JClass jclass) { + return super.getClassName(jclass) + "Marshaller"; + } + + protected String getBaseClassName(JClass jclass) { + String answer = jclass.getSimpleName(); + + if( answer.equals("ActiveMQTextMessage") ) { + answer = "MessageMarshaller"; + } else if( answer.equals("ActiveMQBytesMessage") ) { + answer = "MessageMarshaller"; + } else if( answer.equals("ActiveMQMapMessage") ) { + answer = "MessageMarshaller"; + } else if( answer.equals("ActiveMQObjectMessage") ) { + answer = "MessageMarshaller"; + } else if( answer.equals("ActiveMQStreamMessage") ) { + answer = "MessageMarshaller"; + } else if( answer.equals("ActiveMQBlobMessage") ) { + answer = "MessageMarshaller"; + } + + // We didn't map it directly so we turn it into something generic. + if( answer.equals( jclass.getSimpleName() ) ) { + answer = "BaseDataStreamMarshaller"; + JClass superclass = jclass.getSuperclass(); + if (superclass != null) { + String superName = superclass.getSimpleName(); + if (!superName.equals("Object") && !superName.equals("JNDIBaseStorable") && !superName.equals("DataStructureSupport")) { + answer = superName + "Marshaller"; + } + } + return answer; + } + + return answer; + } + + public boolean isMarshallAware(JClass j) { + + String answer = jclass.getSimpleName(); + + if( answer.equals("ActiveMQTextMessage") ) { + return true; + } else if( answer.equals("ActiveMQBytesMessage") ) { + return true; + } else if( answer.equals("ActiveMQMapMessage") ) { + return true; + } else if( answer.equals("ActiveMQObjectMessage") ) { + return true; + } else if( answer.equals("ActiveMQStreamMessage") ) { + return true; + } else if( answer.equals("ActiveMBlobMessage") ) { + return true; + } else { + return super.isMarshallAware(jclass); + } + } + + protected String getFilePostFix() { + return ".h"; + } + + public String toCppType(JClass type) { + String name = type.getSimpleName(); + if (name.equals("String")) { + return "std::string"; + } + else if( type.isArrayType() ) { + if( name.equals( "byte[]" ) ) + name = "unsigned char[]"; + + JClass arrayClass = type.getArrayComponentType(); + + if( arrayClass.isPrimitiveType() ) { + return "std::vector<" + name.substring(0, name.length()-2) + ">"; + } else { + return "std::vector<" + name.substring(0, name.length()-2) + "*>"; + } + } + else if( name.equals( "Throwable" ) || name.equals( "Exception" ) ) { + return "BrokerError"; + } + else if( name.equals("BaseDataStructure" ) ){ + return "DataStructure"; + } + else if( name.equals("ByteSequence") ) { + return "std::vector"; + } + else if( name.equals("boolean") ) { + return "bool"; + } + else if( name.equals("long") ) { + return "long long"; + } + else if( name.equals("byte") ) { + return "unsigned char"; + } + else if( !type.isPrimitiveType() ) { + return name; + } + else { + return name; + } + } + + protected void generateLicence(PrintWriter out) { +out.println("/*"); +out.println(" * Licensed to the Apache Software Foundation (ASF) under one or more"); +out.println(" * contributor license agreements. See the NOTICE file distributed with"); +out.println(" * this work for additional information regarding copyright ownership."); +out.println(" * The ASF licenses this file to You under the Apache License, Version 2.0"); +out.println(" * (the \"License\"); you may not use this file except in compliance with"); +out.println(" * the License. You may obtain a copy of the License at"); +out.println(" *"); +out.println(" * http://www.apache.org/licenses/LICENSE-2.0"); +out.println(" *"); +out.println(" * Unless required by applicable law or agreed to in writing, software"); +out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,"); +out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."); +out.println(" * See the License for the specific language governing permissions and"); +out.println(" * limitations under the License."); +out.println(" */"); + } + + protected void generateFile(PrintWriter out) throws Exception { + generateLicence(out); + +out.println(""); +out.println("#ifndef _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_"+className.toUpperCase()+"_H_"); +out.println("#define _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_"+className.toUpperCase()+"_H_"); +out.println(""); +out.println("// Turn off warning message for ignored exception specification"); +out.println("#ifdef _MSC_VER"); +out.println("#pragma warning( disable : 4290 )"); +out.println("#endif"); +out.println(""); + + if( baseClass.equals("BaseDataStreamMarshaller") ) { + out.println("#include "); + } else { + out.println("#include "); + } + +out.println(""); +out.println("#include "); +out.println("#include "); +out.println("#include "); +out.println("#include "); +out.println("#include "); +out.println("#include "); +out.println("#include "); +out.println(""); +out.println("namespace activemq{"); +out.println("namespace wireformat{"); +out.println("namespace openwire{"); +out.println("namespace marshal{"); +out.println("namespace v"+getOpenwireVersion()+"{"); +out.println(""); +out.println(" /**"); +out.println(" * Marshaling code for Open Wire Format for "+className); +out.println(" *"); +out.println(" * NOTE!: This file is auto generated - do not modify!"); +out.println(" * if you need to make a change, please see the Java Classes"); +out.println(" * in the activemq-openwire-generator module"); +out.println(" */"); +out.println(" class AMQCPP_API "+className+" : public "+baseClass+" {"); +out.println(" public:"); +out.println(""); +out.println(" "+className+"() {}"); +out.println(" virtual ~"+className+"() {}"); +out.println(""); + + if( !isAbstractClass() ) { + +out.println(" /**"); +out.println(" * Creates a new instance of this marshalable type."); +out.println(" *"); +out.println(" * @return new DataStructure object pointer caller owns it."); +out.println(" */"); +out.println(" virtual commands::DataStructure* createObject() const;"); +out.println(""); +out.println(" /**"); +out.println(" * Get the Data Structure Type that identifies this Marshaler"); +out.println(" *"); +out.println(" * @return byte holding the data structure type value"); +out.println(" */"); +out.println(" virtual unsigned char getDataStructureType() const;"); +out.println(""); + } +out.println(" /**"); +out.println(" * Un-marshal an object instance from the data input stream."); +out.println(" *"); +out.println(" * @param wireFormat - describes the wire format of the broker."); +out.println(" * @param dataStructure - Object to be un-marshaled."); +out.println(" * @param dataIn - BinaryReader that provides that data."); +out.println(" * @param bs - BooleanStream stream used to unpack bits from the wire."); +out.println(" *"); +out.println(" * @throws IOException if an error occurs during the unmarshal."); +out.println(" */"); +out.println(" virtual void tightUnmarshal( OpenWireFormat* wireFormat,"); +out.println(" commands::DataStructure* dataStructure,"); +out.println(" decaf::io::DataInputStream* dataIn,"); +out.println(" utils::BooleanStream* bs ) throw( decaf::io::IOException );"); +out.println(""); +out.println(" /**"); +out.println(" * Write the booleans that this object uses to a BooleanStream"); +out.println(" *"); +out.println(" * @param wireFormat - describes the wire format of the broker"); +out.println(" * @param dataStructure - Object to be marshaled"); +out.println(" * @param bs - BooleanStream stream used to pack bits from the wire."); +out.println(" * @returns int value indicating the size of the marshaled object."); +out.println(" *"); +out.println(" * @throws IOException if an error occurs during the marshal."); +out.println(" */"); +out.println(" virtual int tightMarshal1( OpenWireFormat* wireFormat,"); +out.println(" commands::DataStructure* dataStructure,"); +out.println(" utils::BooleanStream* bs ) throw( decaf::io::IOException );"); +out.println(""); +out.println(" /**"); +out.println(" * Write a object instance to data output stream"); +out.println(" *"); +out.println(" * @param wireFormat - describes the wire format of the broker"); +out.println(" * @param dataStructure - Object to be marshaled"); +out.println(" * @param dataOut - BinaryReader that provides that data sink"); +out.println(" * @param bs - BooleanStream stream used to pack bits from the wire."); +out.println(" *"); +out.println(" * @throws IOException if an error occurs during the marshal."); +out.println(" */"); +out.println(" virtual void tightMarshal2( OpenWireFormat* wireFormat,"); +out.println(" commands::DataStructure* dataStructure,"); +out.println(" decaf::io::DataOutputStream* dataOut,"); +out.println(" utils::BooleanStream* bs ) throw( decaf::io::IOException );"); +out.println(""); +out.println(" /**"); +out.println(" * Un-marshal an object instance from the data input stream"); +out.println(" *"); +out.println(" * @param wireFormat - describes the wire format of the broker"); +out.println(" * @param dataStructure - Object to be marshaled"); +out.println(" * @param dataIn - BinaryReader that provides that data source"); +out.println(" *"); +out.println(" * @throws IOException if an error occurs during the unmarshal."); +out.println(" */"); +out.println(" virtual void looseUnmarshal( OpenWireFormat* wireFormat,"); +out.println(" commands::DataStructure* dataStructure,"); +out.println(" decaf::io::DataInputStream* dataIn ) throw( decaf::io::IOException );"); +out.println(""); +out.println(" /**"); +out.println(" * Write a object instance to data output stream"); +out.println(" *"); +out.println(" * @param wireFormat - describs the wire format of the broker"); +out.println(" * @param dataStructure - Object to be marshaled"); +out.println(" * @param dataOut - BinaryWriter that provides that data sink"); +out.println(" *"); +out.println(" * @throws IOException if an error occurs during the marshal."); +out.println(" */"); +out.println(" virtual void looseMarshal( OpenWireFormat* wireFormat,"); +out.println(" commands::DataStructure* dataStructure,"); +out.println(" decaf::io::DataOutputStream* dataOut ) throw( decaf::io::IOException );"); +out.println(""); +out.println(" };"); +out.println(""); +out.println("}}}}}"); +out.println(""); +out.println("#endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_"+className.toUpperCase()+"_H_*/"); +out.println(""); + } + + protected void processFactory() { + if (factoryFile == null) { + factoryFile = new File(destDir, factoryFileName + filePostFix); + } + PrintWriter out = null; + try { + out = new PrintWriter(new FileWriter(factoryFile)); + generateFactory(out); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + if (out != null) { + out.close(); + } + } + } + + public void generateFactory(PrintWriter out) { + generateLicence(out); +out.println("#ifndef _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_MARSHALERFACTORY_H_"); +out.println("#define _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_MARSHALERFACTORY_H_"); +out.println(""); +out.println("// Turn off warning message for ignored exception specification"); +out.println("#ifdef _MSC_VER"); +out.println("#pragma warning( disable : 4290 )"); +out.println("#endif"); +out.println(""); +out.println("#include "); +out.println(""); +out.println("namespace activemq{"); +out.println("namespace wireformat{"); +out.println("namespace openwire{"); +out.println("namespace marshal{"); +out.println("namespace v"+getOpenwireVersion()+"{"); +out.println(""); +out.println(" /**"); +out.println(" * Used to create marshallers for a specific version of the wire"); +out.println(" * protocol."); +out.println(" *"); +out.println(" * NOTE!: This file is auto generated - do not modify!"); +out.println(" * if you need to make a change, please see the Groovy scripts"); +out.println(" * in the activemq-openwire-generator module"); +out.println(" */"); +out.println(" class MarshallerFactory {"); +out.println(" public:"); +out.println(""); +out.println(" virtual ~MarshallerFactory() {};"); +out.println(""); +out.println(" virtual void configure( OpenWireFormat* format );"); +out.println(""); +out.println(" };"); +out.println(""); +out.println("}}}}}"); +out.println(""); +out.println("#endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_V"+getOpenwireVersion()+"_MARSHALLERFACTORY_H_*/"); + } + + public List getConcreteClasses() { + return concreteClasses; + } + + public void setConcreteClasses(List concreteClasses) { + this.concreteClasses = concreteClasses; + } + + public String getTargetDir() { + return targetDir; + } + + public void setTargetDir(String targetDir) { + this.targetDir = targetDir; + } +} Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ.Openwire.Generator/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native