activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r471943 - /incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/
Date Tue, 07 Nov 2006 00:21:55 GMT
Author: tabish
Date: Mon Nov  6 16:21:55 2006
New Revision: 471943

URL: http://svn.apache.org/viewvc?view=rev&rev=471943
Log:
Cleanup CMS Files for planned release.

Added:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java   (with props)

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java?view=auto&rev=471943
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java Mon Nov  6 16:21:55 2006
@@ -0,0 +1,411 @@
+/*
+ *
+ * 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.openwire.tool;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+
+/**
+ * 
+ * @version $Revision: 409828 $
+ */
+public class AmqCppClassesGenerator extends MultiSourceGenerator {
+
+	protected String targetDir="./src/main";
+
+    public Object run() {
+        filePostFix = getFilePostFix();
+        if (destDir == null) {
+            destDir = new File(
+                targetDir+"/activemq/connector/openwire/commands");
+        }
+        return super.run();
+    }
+
+    protected String getFilePostFix() {
+        return ".cpp";
+    }
+
+    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 = "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<char>";
+        }
+        else if( name.equals("boolean") ) {
+            return "bool";
+        }
+        else if( name.equals("long") ) {
+            return "long long";
+        }
+        else if( name.equals("byte") ) {
+            return "char";
+        }
+        else if( !type.isPrimitiveType() ) {
+            return name;
+        }
+        else {
+            return name;
+        }
+    }
+
+    /**
+     * Converts the Java type to a C++ default value
+     */
+    public 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";
+        }
+    }
+
+    /**
+     * Converts the Java type to the name of the C++ marshal method to be used
+     */
+    public String toMarshalMethodName(JClass type) {
+        String name = type.getSimpleName();
+        if (name.equals("String")) {
+            return "marshalString";
+        } else if (type.isArrayType()) {
+            if (type.getArrayComponentType().isPrimitiveType()
+                    && name.equals("byte[]"))
+                return "marshalByteArray";
+            else
+                return "marshalObjectArray";
+        } else if (name.equals("ByteSequence")) {
+            return "marshalByteArray";
+        } else if (name.equals("short")) {
+            return "marshalShort";
+        } else if (name.equals("int")) {
+            return "marshalInt";
+        } else if (name.equals("long")) {
+            return "marshalLong";
+        } else if (name.equals("byte")) {
+            return "marshalByte";
+        } else if (name.equals("double")) {
+            return "marshalDouble";
+        } else if (name.equals("float")) {
+            return "marshalFloat";
+        } else if (name.equals("boolean")) {
+            return "marshalBoolean";
+        } else if (!type.isPrimitiveType()) {
+            return "marshalObject";
+        } else {
+            return name;
+        }
+    }
+
+    /**
+     * Converts the Java type to the name of the C++ unmarshal method to be used
+     */
+    public String toUnmarshalMethodName(JClass type) {
+        String name = type.getSimpleName();
+        if (name.equals("String")) {
+            return "unmarshalString";
+        } else if (type.isArrayType()) {
+            if (type.getArrayComponentType().isPrimitiveType()
+                    && name.equals("byte[]"))
+                return "unmarshalByteArray";
+            else
+                return "unmarshalObjectArray";
+        } else if (name.equals("ByteSequence")) {
+            return "unmarshalByteArray";
+        } else if (name.equals("short")) {
+            return "unmarshalShort";
+        } else if (name.equals("int")) {
+            return "unmarshalInt";
+        } else if (name.equals("long")) {
+            return "unmarshalLong";
+        } else if (name.equals("byte")) {
+            return "unmarshalByte";
+        } else if (name.equals("double")) {
+            return "unmarshalDouble";
+        } else if (name.equals("float")) {
+            return "unmarshalFloat";
+        } else if (name.equals("boolean")) {
+            return "unmarshalBoolean";
+        } else if (!type.isPrimitiveType()) {
+            return "unmarshalObject";
+        } else {
+            return name;
+        }
+    }
+
+    /**
+     * Converts the Java type to a C++ pointer cast
+     */
+    public String toUnmarshalCast(JClass type) {
+        String name = toCppType(type);
+
+        if (name.startsWith("p<"))
+            return "p_cast<" + name.substring(2);
+        else if (name.startsWith("array<")
+                && (type.isArrayType() && !type.getArrayComponentType()
+                        .isPrimitiveType())
+                && !type.getSimpleName().equals("ByteSequence"))
+            return "array_cast<" + name.substring(6);
+        else
+            return "";
+    }
+    
+	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("#include <activemq/connector/openwire/commands/"+className+".h>");
+out.println("");
+out.println("using namespace std;");
+out.println("using namespace activemq;");
+out.println("using namespace activemq::connector;");
+out.println("using namespace activemq::connector::openwire;");
+out.println("using namespace activemq::connector::openwire::commands;");
+out.println("");
+out.println("/*");
+out.println(" *");
+out.println(" *  Command and marshalling code for OpenWire format for "+className+"");
+out.println(" *");
+out.println(" *");
+out.println(" *  NOTE!: This file is autogenerated - do not modify!");
+out.println(" *         if you need to make a change, please see the Java Classes in the");
+out.println(" *         activemq-core module");
+out.println(" *");
+out.println(" */");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println(""+className+"::"+className+"()");
+out.println("{");
+
+		List properties = getProperties();
+		for (Iterator iter = properties.iterator(); iter.hasNext();) {
+			JProperty property = (JProperty) iter.next();
+            String type = toCppType(property.getType());
+	        String value = toCppDefaultValue(property.getType());
+	        String propertyName = property.getSimpleName();
+	        String parameterName = decapitalize(propertyName);
+            
+            if( !type.startsWith("std::vector") ) {
+out.println("    this->"+parameterName+" = "+value+";");
+            }
+		}
+out.println("}");
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println(""+className+"::~"+className+"()");
+out.println("{");
+
+    for( Iterator iter = properties.iterator(); iter.hasNext(); ) {
+        JProperty property = (JProperty) iter.next();
+        String type = toCppType(property.getType());
+        String propertyName = property.getSimpleName();
+        String parameterName = decapitalize(propertyName);
+    
+        if( property.getType().isPrimitiveType() ||
+            property.getType().getSimpleName().equals("String") ) {
+            continue;
+        }
+        
+        if( !type.startsWith("std::vector" ) ) {
+out.println("    delete this->" + parameterName + ";");
+        } else if( type.contains( "*" ) ) {
+out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < " + parameterName + ".size(); ++i" + parameterName + " ) {");
+out.println("        delete " + parameterName + "[i" + parameterName + "];");
+out.println("    }");
+        }
+    }
+out.println("}");
+
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println(className+"* "+className+"::clone() const {");
+
+    String newInstance = decapitalize( className );
+
+out.println("    "+className+"* "+newInstance+" = new "+className+"();");
+out.println("");
+
+    if( baseClass != null ) {
+out.println("    // Copy the data from the base class or classes");
+out.println("    "+baseClass+"::copy( "+newInstance+" );");
+out.println("");
+    }
+    
+    for( Iterator iter = properties.iterator(); iter.hasNext(); ) {
+        JProperty property = (JProperty) iter.next();
+        String type = toCppType(property.getType());
+        String propertyName = property.getSimpleName();
+        String parameterName = decapitalize(propertyName);
+        String constNess = "";
+    
+        if( !property.getType().isPrimitiveType() &&
+            !property.getType().getSimpleName().equals("ByteSequence") && 
+            !type.startsWith("std::vector") ) {
+
+out.println("    "+newInstance+"->"+parameterName+" = this->get"+propertyName+"();");
+        } else if( property.getType().isArrayType() &&
+                !property.getType().getArrayComponentType().isPrimitiveType() ) {
+out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < " + parameterName + ".size(); ++i" + parameterName + " ) {");
+out.println("        "+newInstance+"->get"+propertyName+"().push_back( ");
+out.println("            this->"+parameterName+"[i"+parameterName+"]->clone();");            
+out.println("    }");
+        } else {
+out.println("    "+newInstance+"->"+parameterName+" = this->get"+propertyName+"()->clone();");
+        }
+    }
+
+out.println("");
+out.println("    return "+newInstance);
+out.println("}");
+
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println("void "+className+"::copy( "+className+"* dest ) const {");
+out.println("");
+
+        if( baseClass != null ) {
+out.println("    // Copy the data from the base class or classes");
+out.println("    "+baseClass+"::copy( "+newInstance+" );");
+out.println("");
+        }
+
+    for( Iterator iter = properties.iterator(); iter.hasNext(); ) {
+        JProperty property = (JProperty) iter.next();
+        String type = toCppType(property.getType());
+        String propertyName = property.getSimpleName();
+        String parameterName = decapitalize(propertyName);
+        String constNess = "";
+    
+        if( !property.getType().isPrimitiveType() &&
+            !property.getType().getSimpleName().equals("ByteSequence") && 
+            !type.startsWith("std::vector") ) {
+    
+    out.println("    dest->set"+propertyName+"( this->get"+propertyName+"() );");
+        } else if( property.getType().isArrayType() &&
+                   !property.getType().getArrayComponentType().isPrimitiveType() ) {
+    out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < " + parameterName + ".size(); ++i" + parameterName + " ) {");
+    out.println("        dest->get"+propertyName+"().push_back( ");
+    out.println("            this->"+parameterName+"[i"+parameterName+"]->clone() );");            
+    out.println("    }");
+        } else {
+    out.println("    dest->set"+propertyName+"( this->get"+propertyName+"()->clone() );");
+        }
+    }
+
+out.println("}");
+
+
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println("unsigned char "+className+"::getDataStructureType() const {");
+out.println("    return "+className+"::ID_" + className.toUpperCase() + "; ");
+out.println("}");
+
+       for( Iterator iter = properties.iterator(); iter.hasNext(); ) {
+			JProperty property = (JProperty) iter.next();
+	        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 = type + "*";
+            } else if( property.getType().getSimpleName().equals("String") ) {
+                type = type + "&";
+                constNess = "const ";
+            }
+
+           
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println("const "+type+" "+className+"::get"+propertyName+"() const {");
+out.println("    return "+parameterName+";");
+out.println("}");
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println(""+type+" "+className+"::get"+propertyName+"() {");
+out.println("    return "+parameterName+";");
+out.println("}");
+out.println("");
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println("void " + className + "::set" + propertyName+"(" + constNess + type+ " " + parameterName +" ) {");
+out.println("    this->"+parameterName+" = "+parameterName+";");
+out.println("}");
+	    }
+out.println("");
+	}
+
+	public String getTargetDir() {
+		return targetDir;
+	}
+
+	public void setTargetDir(String targetDir) {
+		this.targetDir = targetDir;
+	}
+	
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java?view=auto&rev=471943
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java Mon Nov  6 16:21:55 2006
@@ -0,0 +1,136 @@
+/**
+ *
+ * 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.openwire.tool;
+
+import java.io.File;
+
+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;
+
+/**
+ * 
+ * @version $Revision: 384826 $
+ */
+public class AmqCppGeneratorTask extends Task {
+	
+	int version = 2;
+	File source = new File(".");
+	File target = new File(".");
+	
+    public static void main(String[] args) {
+    	
+        Project project = new Project();
+        project.init();
+    	AmqCppGeneratorTask generator = new AmqCppGeneratorTask();
+    	generator.setProject(project);
+    	
+    	if( args.length > 0 ) {
+    		generator.version = Integer.parseInt(args[0]);
+            System.out.println( "Generator 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);
+
+            {
+            	AmqCppClassesGenerator script = new AmqCppClassesGenerator();
+	        	script.setJam(jam);
+	        	script.setTargetDir(target+"/src/main");
+	        	script.setOpenwireVersion(version);
+	        	script.run();
+            }
+            {
+                AmqCppHeadersGenerator script = new AmqCppHeadersGenerator();
+	        	script.setJam(jam);
+	        	script.setTargetDir(target+"/src/main");
+	        	script.setOpenwireVersion(version);
+	        	script.run();
+            }
+            {
+                AmqCppMarshallingHeadersGenerator script = new AmqCppMarshallingHeadersGenerator();
+	        	script.setJam(jam);
+	        	script.setTargetDir(target+"/src/main");
+	        	script.setOpenwireVersion(version);
+	        	script.run();
+            }
+            {
+                AmqCppMarshallingClassesGenerator script = new AmqCppMarshallingClassesGenerator();
+	        	script.setJam(jam);
+	        	script.setTargetDir(target+"/src/main");
+	        	script.setOpenwireVersion(version);
+	        	script.run();
+            }
+            
+            
+        } catch (Exception e) {
+        	throw new BuildException(e);
+        }
+    }
+
+	public int getVersion() {
+		return version;
+	}
+
+	public void setVersion(int version) {
+		this.version = 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: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppGeneratorTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java?view=auto&rev=471943
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java Mon Nov  6 16:21:55 2006
@@ -0,0 +1,181 @@
+/**
+ *
+ * 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.openwire.tool;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+
+
+/**
+ *
+ * @version $Revision: 379734 $
+ */
+public class AmqCppHeadersGenerator extends AmqCppClassesGenerator {
+
+    protected String getFilePostFix() {
+        return ".h";
+    }
+    
+	protected void generateFile(PrintWriter out) {
+		generateLicence(out);		
+
+out.println("");
+out.println("#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_"+className.toUpperCase()+"_H_");
+out.println("#define _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_"+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("");
+out.println("#include <activemq/connector/openwire/commands/"+baseClass+".h>");
+
+List properties = getProperties();
+for (Iterator iter = properties.iterator(); iter.hasNext();) {
+    JProperty property = (JProperty) iter.next();
+    if( !property.getType().isPrimitiveType() &&
+        !property.getType().getSimpleName().equals("String") &&
+        !property.getType().getSimpleName().equals("ByteSequence") )
+    {
+        String includeName = toCppType(property.getType());
+        if( property.getType().isArrayType() )
+        {
+            JClass arrayType = property.getType().getArrayComponentType();
+            if( arrayType.isPrimitiveType() )
+                continue;
+        }
+        if( includeName.startsWith("std::vector") ) {
+            includeName = includeName.substring(12, includeName.length()-2);
+        }
+
+        out.println("#include <activemq/connector/openwire/commands/"+includeName+".h>");
+    }
+}
+
+out.println("#include <vector>");
+out.println("#include <string>");
+out.println("");
+out.println("namespace activemq{");
+out.println("namespace connector{");
+out.println("namespace openwire{");
+out.println("namespace commands{");
+out.println("");
+out.println("    /*");
+out.println("     *");
+out.println("     *  Command and marshalling code for OpenWire format for ${className}");
+out.println("     *");
+out.println("     *");
+out.println("     *  NOTE!: This file is autogenerated - 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("     */");
+out.println("    class "+className+" : public "+baseClass);
+out.println("    {");
+out.println("    protected:");
+out.println("");
+
+       for (Iterator iter = properties.iterator(); iter.hasNext();) {
+            JProperty property = (JProperty) iter.next();
+            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 = type + "*";
+            }
+            
+            out.println("        "+type+" "+name+";");
+
+       }
+    
+        String typeName = className.toUpperCase();
+    
+out.println("");
+out.println("    public:");
+out.println("");    
+out.println("        const static unsigned char ID_"+typeName+" = "+getOpenWireOpCode(jclass)+";");
+out.println("");    
+out.println("    public:");
+out.println("");    
+out.println("        "+className+"();");
+out.println("        virtual ~"+className+"();");
+out.println("");    
+out.println("        /**");
+out.println("         * Get the unique identifier that this object and its own");      
+out.println("         * Marshaller 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 obbject 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 "+className+"* clone() const;");
+out.println("");
+out.println("        /**");
+out.println("         * Copy the contents of this object and place them into the");      
+out.println("         * instance of this object type that was passed in.");
+out.println("         * @return dest - Destination Object");
+out.println("         */");
+out.println("        virtual void clone( "+className+"* dest ) const;");
+out.println("");
+
+        for( Iterator iter = properties.iterator(); iter.hasNext(); ) {
+            JProperty property = (JProperty) iter.next();
+            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 = type + "*";
+            } else if( property.getType().getSimpleName().equals("String") ) {
+                type = type + "&";
+                constness = "const ";
+            }
+            
+            out.println("        virtual const "+type+" get"+propertyName+"() const;");
+            out.println("        virtual "+type+" get"+propertyName+"();");
+            out.println("        virtual void set"+propertyName+"( "+constness+type+" "+parameterName+" );");
+            out.println("");
+        }
+
+out.println("    };");
+out.println("");
+out.println("}}}}");
+out.println("");
+out.println("#endif /*_ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_"+className.toUpperCase()+"_H_*/");
+out.println("");
+
+    }    
+
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java?view=auto&rev=471943
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java Mon Nov  6 16:21:55 2006
@@ -0,0 +1,615 @@
+/**
+ *
+ * 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.openwire.tool;
+
+import org.codehaus.jam.JAnnotation;
+import org.codehaus.jam.JAnnotationValue;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ *
+ * @version $Revision: 381410 $
+ */
+public class AmqCppMarshallingClassesGenerator extends AmqCppMarshallingHeadersGenerator {
+
+    protected String getFilePostFix() {
+        return ".cpp";
+    }
+
+    //////////////////////////////////////////////////////////////////////////////////////
+    // This section is for the tight wire format encoding generator
+    //////////////////////////////////////////////////////////////////////////////////////
+
+    protected void generateTightUnmarshalBodyForProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
+
+        String setter = property.getSetter().getSimpleName();
+        String type = property.getType().getSimpleName();
+        String propertyName = property.getType().getSimpleName();
+
+        if( type.equals("boolean") ) {
+            out.println("    info->" + setter + "( bs->readBoolean() );");
+        }
+        else if( type.equals("byte") ) {
+            out.println("    info->" + setter + "( dataIn->readByte() );");
+        }
+        else if( type.equals("char") ) {
+            out.println("    info->" + setter + "( dataIn->readChar() );");
+        }
+        else if( type.equals("short") ) {
+            out.println("    info->" + setter + "( dataIn->readShort() );");
+        }
+        else if( type.equals("int") ) {
+            out.println("    info->" + setter + "( dataIn->readInt() );");
+        }
+        else if( type.equals("long") ) {
+            out.println("    info->" + setter + "( TightUnmarshalLong( wireFormat, dataIn, bs ) );");
+        }
+        else if( type.equals("String") ) {
+            out.println("    info->" + setter + "( TightUnmarshalString( dataIn, bs ) );");
+        }
+        else if( type.equals("byte[]") || type.equals("ByteSequence") ) {
+            if( size != null ) {
+                out.println("    info->" + setter + "( tightUnmarshalConstByteArray( dataIn, bs, "+ size.asInt() +" ) );");
+            }
+            else {
+                out.println("    info->" + setter + "( tightUnmarshalByteArray( dataIn, bs ) );");
+            }
+        }
+        else if (isThrowable(property.getType())) {
+            out.println("    info->" + setter + "( dynamic_cast< " + propertyName + "* >(");
+            out.println("        tightUnmarsalThrowable( wireFormat, dataIn, bs ) );");
+        }
+        else if (isCachedProperty(property)) {
+            out.println("    info->" + setter + "( dynamic_cast< " + propertyName + "* >(");
+            out.println("        tightUnmarsalCachedObject( wireFormat, dataIn, bs ) );");
+        }
+        else {
+            out.println("    info->" + setter + "( dynamic_cast< " + propertyName + "* >(");
+            out.println("        tightUnmarsalNestedObject( wireFormat, dataIn, bs ) );");
+        }
+    }
+
+    protected void generateTightUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
+        JClass propertyType = property.getType();
+        String arrayType = propertyType.getArrayComponentType().getSimpleName();
+        String setter = property.getSetter().getSimpleName();
+        out.println();
+        if (size != null) {
+            out.println("    {");
+            out.println("        " + arrayType + " value[] = new " + arrayType + "[" + size.asInt() + "];");
+            out.println("        " + "for( int i = 0; i < " + size.asInt() + "; i++ ) {");
+            out.println("            value[i] = (" + arrayType + ") tightUnmarsalNestedObject( wireFormat,dataIn, bs );");
+            out.println("        }");
+            out.println("        info->" + setter + "( value );");
+            out.println("    }");
+        }
+        else {
+            out.println("    if( bs->readBoolean() ) {");
+            out.println("        short size = dataIn->readShort();");
+            out.println("        " + arrayType + "* value = new " + arrayType + "[size];");
+            out.println("        for( int i = 0; i < size; i++ ) {");
+            out.println("            value[i] = dynamic_cast< " + arrayType + "* >(");
+            out.println("                tightUnmarsalNestedObject( wireFormat, dataIn, bs ) );");
+            out.println("        }");
+            out.println("        info->" + setter + "( value );");
+            out.println("    }");
+            out.println("    else {");
+            out.println("        info->" + setter + "( NULL );");
+            out.println("    }");
+        }
+    }
+    
+    protected int generateTightMarshal1Body(PrintWriter out) {
+        List properties = getProperties();
+        int baseSize = 0;
+        for (Iterator iter = properties.iterator(); iter.hasNext();) {
+            JProperty property = (JProperty) iter.next();
+            JAnnotation annotation = property.getAnnotation("openwire:property");
+            JAnnotationValue size = annotation.getValue("size");
+            JClass propertyType = property.getType();
+            String type = propertyType.getSimpleName();
+            String getter = "info->" + property.getGetter().getSimpleName() + "()";
+
+            if (type.equals("boolean")) {
+                out.println("    bs->writeBoolean( " + getter + " );");
+            }
+            else if (type.equals("byte")) {
+                baseSize += 1;
+            }
+            else if (type.equals("char")) {
+                baseSize += 2;
+            }
+            else if (type.equals("short")) {
+                baseSize += 2;
+            }
+            else if (type.equals("int")) {
+                baseSize += 4;
+            }
+            else if (type.equals("long")) {
+                out.println("    rc += tightMarshalLong1( wireFormat, " + getter + ", bs );");
+            }
+            else if (type.equals("String")) {
+                out.print("");
+                out.println("    rc += tightMarshalString1( " + getter + ", bs );" );
+            }
+            else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+                if (size == null) {
+                    out.println("    bs->writeBoolean( " + getter + " != NULL );" );
+                    out.println("    rc += " + getter + "() == NULL ? 0 : " + getter + ".Length + 4;");
+                }
+                else {
+                    baseSize += size.asInt();
+                }
+            }
+            else if (propertyType.isArrayType()) {
+                if (size != null) {
+                    out.println("    rc += tightMarshalObjectArrayConstSize1( wireFormat, " + getter + ", bs, " + size.asInt() + " );");
+                }
+                else {
+                    out.println("    rc += tightMarshalObjectArray1( wireFormat, " + getter + ", bs );");
+                }
+            }
+            else if (isThrowable(propertyType)) {
+                out.println("    rc += tightMarshalBrokerError1( wireFormat, " + getter + ", bs );");
+            }
+            else {
+                out.println( "    DataStructure* data = " );
+                out.println( "        dynamic_cast< DataStructure* >( " + getter + " );\n" );
+
+                if (isCachedProperty(property)) {
+                    out.println("    rc += tightMarshalCachedObject1( wireFormat, data, bs );");
+                }
+                else {
+                    out.println("    rc += tightMarshalNestedObject1( wireFormat, data, bs );");
+                }
+            }
+        }
+        return baseSize;
+    }
+
+    protected void generateTightMarshal2Body(PrintWriter out) {
+        List properties = getProperties();
+        for (Iterator iter = properties.iterator(); iter.hasNext();) {
+            JProperty property = (JProperty) iter.next();
+            JAnnotation annotation = property.getAnnotation("openwire:property");
+            JAnnotationValue size = annotation.getValue("size");
+            JClass propertyType = property.getType();
+            String type = propertyType.getSimpleName();
+            String getter = "info->" + property.getGetter().getSimpleName() + "()";
+
+            if (type.equals("boolean")) {
+                out.println("    bs->readBoolean();");
+            }
+            else if (type.equals("byte")) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if (type.equals("char")) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if (type.equals("short")) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if (type.equals("int")) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if (type.equals("long")) {
+                out.println("    tightMarshalLong2( wireFormat, " + getter + ", dataOut, bs );");
+            }
+            else if (type.equals("String")) {
+                out.println("    tightMarshalString2( " + getter + ", dataOut, bs );");
+            }
+            else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+                if (size != null) {
+                    out.println("    dataOut->write( " + getter + ", 0, " + size.asInt() + " );");
+                }
+                else {
+                    out.println("    if( bs->readBoolean() ) {");
+                    out.println("        dataOut->write( " + getter + ".Length );");
+                    out.println("        dataOut->write( " + getter + " );");
+                    out.println("    }");
+                }
+            }
+            else if (propertyType.isArrayType()) {
+                if (size != null) {
+                    out.println("    tightMarshalObjectArrayConstSize2( wireFormat, " + getter + ", dataOut, bs, " + size.asInt() + " );");
+                }
+                else {
+                    out.println("    tightMarshalObjectArray2( wireFormat, " + getter + ", dataOut, bs );");
+                }
+            }
+            else if( isThrowable(propertyType) ) {
+                out.println("    tightMarshalBrokerError2( wireFormat, " + getter + ", dataOut, bs );");
+            }
+            else {
+                out.println( "    DataStructure* data = " );
+                out.println( "        dynamic_cast< DataStructure* >( " + getter + " );\n" );
+
+                if( isCachedProperty(property) ) {
+                    out.println("    tightMarshalCachedObject2( wireFormat, data, dataOut, bs );");
+                }
+                else {
+                    out.println("    tightMarshalNestedObject2( wireFormat, data, dataOut, bs );");
+                }
+            }
+        }
+    }
+    
+    //////////////////////////////////////////////////////////////////////////////////////
+    // This section is for the loose wire format encoding generator
+    //////////////////////////////////////////////////////////////////////////////////////
+    
+    protected void generateLooseUnmarshalBodyForProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
+
+        String propertyName = property.getSimpleName();
+        String type = property.getType().getSimpleName();
+        String setter = property.getSetter().getSimpleName();
+
+        if (type.equals("boolean")) {
+            out.println("    info->" + setter + "( dataIn->readBoolean() );");
+        }
+        else if (type.equals("byte")) {
+            out.println("    info->" + setter + "( dataIn->readByte() );");
+        }
+        else if (type.equals("char")) {
+            out.println("    info->" + setter + "( dataIn->readChar() );");
+        }
+        else if (type.equals("short")) {
+            out.println("    info->" + setter + "( dataIn->readShort() );");
+        }
+        else if (type.equals("int")) {
+            out.println("    info->" + setter + "( dataIn->readInt() );");
+        }
+        else if (type.equals("long")) {
+            out.println("    info->" + setter + "( looseUnmarshalLong( wireFormat, dataIn ) );");
+        }
+        else if (type.equals("String")) {
+            out.println("    info->" + setter + "( looseUnmarshalString( dataIn ) );");
+        }
+        else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+            if (size != null) {
+                out.println("    info->" + setter + "( looseUnmarshalConstByteArray( dataIn, " + size.asInt() + " ) );");
+            }
+            else {
+                out.println("    info->" + setter + "( looseUnmarshalByteArray( dataIn ) );");
+            }
+        }
+        else if (isThrowable(property.getType())) {
+            out.println("    info->" + setter + "( looseUnmarshalBrokerError( wireFormat, dataIn ) );");
+        }
+        else if (isCachedProperty(property)) {
+            out.println("   info->" + setter + "( dynamic_cast<" + type + "* >( ");
+            out.println("       looseUnmarshalCachedObject( wireFormat, dataIn ) ) );");
+        }
+        else {
+            out.println("   info->" + setter + "( dynamic_cast<" + type + "* >( ");
+            out.println("       looseUnmarshalNestedObject( wireFormat, dataIn ) ) );");
+        }
+    }
+
+    protected void generateLooseUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
+        JClass propertyType = property.getType();
+        String arrayType = propertyType.getArrayComponentType().getSimpleName();
+        String propertyName = property.getSimpleName();
+        String setter = property.getSetter().getSimpleName();
+
+        out.println();
+        if (size != null) {
+            out.println("    {");
+            out.println("        " + arrayType + "[] value = new " + arrayType + "[" + size.asInt() + "];");
+            out.println("        " + "for( int i=0; i < " + size.asInt() + "; i++ ) {");
+            out.println("            value[i] = (" + arrayType + ") looseUnmarshalNestedObject( wireFormat, dataIn );");
+            out.println("        }");
+            out.println("        info->" + setter + "( value );");
+            out.println("    }");
+        }
+        else {
+            out.println("    if( dataIn->readBoolean() ) {");
+            out.println("        short size = dataIn->readShort();");
+            out.println("        " + arrayType + "* value = new " + arrayType + "[size];");
+            out.println("        for( int i = 0; i < size; i++ ) {");
+            out.println("            value[i] = dynamic_cast<" + arrayType + "* >(");
+            out.println("                looseUnmarshalNestedObject( wireFormat,dataIn ) );");
+            out.println("        }");
+            out.println("        info->" + setter + "( value );");
+            out.println("    }");
+            out.println("    else {");
+            out.println("        info->" + setter + "( NULL );");
+            out.println("    }");
+        }
+    }
+
+
+    protected void generateLooseMarshalBody(PrintWriter out) {
+        List properties = getProperties();
+        for (Iterator iter = properties.iterator(); iter.hasNext();) {
+            JProperty property = (JProperty) iter.next();
+            JAnnotation annotation = property.getAnnotation("openwire:property");
+            JAnnotationValue size = annotation.getValue("size");
+            JClass propertyType = property.getType();
+            String type = propertyType.getSimpleName();
+            String getter = "info->" + property.getGetter().getSimpleName() + "()";
+
+            if( type.equals( "boolean" ) ) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if( type.equals("byte") ) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if( type.equals("char") ) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if( type.equals("short") ) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if( type.equals("int")) {
+                out.println("    dataOut->write( " + getter + " );");
+            }
+            else if( type.equals("long") ) {
+                out.println("    looseMarshalLong( wireFormat, " + getter + ", dataOut );");
+            }
+            else if( type.equals("String") ) {
+                out.println("    looseMarshalString( " + getter + ", dataOut );");
+            }
+            else if( type.equals("byte[]") || type.equals("ByteSequence") ) {
+                if(size != null) {
+                    out.println("    dataOut->write( " + getter + ", 0, " + size.asInt() + " );");
+                }
+                else {
+                    out.println("    dataOut->write( " + getter + " != NULL );");
+                    out.println("    if( " + getter + " != NULL ) {");
+                    out.println("        dataOut->write( " + getter + ".Length );");
+                    out.println("        dataOut->write( " + getter + " );");
+                    out.println("    }");
+                }
+            }
+            else if( propertyType.isArrayType() ) {
+                if (size != null) {
+                    out.println("    looseMarshalObjectArrayConstSize( wireFormat, " + getter + ", dataOut, " + size.asInt() + " );");
+                }
+                else {
+                    out.println("    looseMarshalObjectArray( wireFormat, " + getter + ", dataOut );");
+                }
+            }
+            else if( isThrowable( propertyType ) ) {
+                out.println("    looseMarshalBrokerError( wireFormat, " + getter + ", dataOut );");
+            }
+            else {
+                out.println( "    DataStructure* data = " );
+                out.println( "        dynamic_cast< DataStructure* >( " + getter + " );\n" );
+                
+                if( isCachedProperty( property ) ) {
+                    out.println("    looseMarshalCachedObject( wireFormat, data, dataOut );");
+                }
+                else {
+                    out.println("    looseMarshalNestedObject( wireFormat, data, dataOut );");
+                }
+            }
+        }
+    }
+    
+    
+	protected void generateFile(PrintWriter out) throws Exception {
+		generateLicence(out);
+		
+out.println("");
+out.println("#include <activemq/connector/openwire/marshal/v"+getOpenwireVersion()+"/"+className+".h>");
+out.println("");
+out.println("#include <activemq/connector/openwire/commands/"+jclass.getSimpleName()+".h>");
+out.println("");
+out.println("//");
+out.println("//     NOTE!: This file is autogenerated - do not modify!");
+out.println("//            if you need to make a change, please see the Java Classes in the");
+out.println("//            activemq-core module");
+out.println("//");
+out.println("");
+out.println("using namespace std;");
+out.println("using namespace activemq;");
+out.println("using namespace activemq::io;");
+out.println("using namespace activemq::connector;");
+out.println("using namespace activemq::connector::openwire;");
+out.println("using namespace activemq::connector::openwire::commands;");
+out.println("using namespace activemq::connector::openwire::marshal;");
+out.println("using namespace activemq::connector::openwire::util;");
+out.println("using namespace activemq::connector::openwire::marshal::v"+getOpenwireVersion()+";");
+out.println("");
+
+    String typeName = jclass.getSimpleName().toUpperCase();
+
+    if( !isAbstractClass() ) {
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("DataStructure* "+className+"::createObject() const {");
+out.println("    return new "+jclass.getSimpleName()+"();");
+out.println("}");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("unsigned char "+className+"::getDataStructureType() const {"); 
+out.println("    return "+jclass.getSimpleName()+"::ID_"+typeName+";");
+out.println("}");
+out.println("");
+    }
+    
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("void "+className+"::tightUnmarshal( OpenWireFormat* wireFormat, DataStructure* dataStructure, DataInputStream* dataIn, BooleanStream* bs ) {");
+out.println("   "+baseClass+"::tightUnmarshal( wireFormat, dataStructure, dataIn, bs );");
+out.println("");
+ 
+    List properties = getProperties();
+    boolean marshallerAware = isMarshallerAware();
+    if( !properties.isEmpty() || marshallerAware ) {
+
+out.println("    "+jclass.getSimpleName()+"* info ="); 
+out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+    }
+
+    if( marshallerAware ) {
+out.println("    info->beforeUnmarshall( wireFormat );");     
+out.println("");
+    }
+
+    generateTightUnmarshalBody(out);
+
+    if( marshallerAware ) {
+out.println("");
+out.println("    info->afterUnmarshall( wireFormat );");
+    }
+    
+out.println("}");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("int "+className+"::tightMarshal1( OpenWireFormat& wireFormat, DataStructure* dataStructure, BooleanStream& bs ) {");
+out.println("");
+
+    if( !properties.isEmpty() ) { 
+out.println("    "+jclass.getSimpleName()+"* info ="); 
+out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+out.println("");
+    }
+        
+    if( marshallerAware ) {
+out.println("    info->beforeMarshall( wireFormat );");
+    }
+
+out.println("    int rc = "+baseClass+"::tightMarshal1( wireFormat, dataStructure, bs );");
+
+    int baseSize = generateTightMarshal1Body(out);
+    
+out.println("");
+out.println("    return rc + "+baseSize+";");
+out.println("}");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("void "+className+"::tightMarshal2( OpenWireFormat& wireFormat, DataStructure* dataStructure, DataOutputStream& dataOut, BooleanStream& bs ) {");
+out.println("");
+out.println("    "+baseClass+"::tightMarshal2( wireFormat, dataStructure, dataOut, bs );");
+out.println("");
+
+    if( !properties.isEmpty() || marshallerAware ) {
+out.println("    "+jclass.getSimpleName()+"* info ="); 
+out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+    }
+
+    generateTightMarshal2Body(out);
+
+    if( marshallerAware ) {
+out.println("    info->afterMarshall( wireFormat );");
+    }
+
+out.println("}");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("void "+className+"::looseUnmarshal( OpenWireFormat& wireFormat, DataStructure* dataStructure, DataInputStream& dataIn ) {");
+out.println("    "+baseClass+"::looseUnmarshal( wireFormat, dataStructure, dataIn );");
+ 
+    if( !properties.isEmpty() || marshallerAware ) {
+out.println("    "+jclass.getSimpleName()+"* info = ");
+out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+    }
+
+    if( marshallerAware ) {
+out.println("    info->beforeUnmarshall( wireFormat );");
+    }
+
+    generateLooseUnmarshalBody(out);
+
+    if( marshallerAware ) {
+out.println("    info->afterUnmarshall( wireFormat );");
+    }
+
+out.println("}");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("void "+className+"::looseMarshal( OpenWireFormat& wireFormat, DataStructure* dataStructure, DataOutputStream& dataOut ) {");
+
+    if( !properties.isEmpty() || marshallerAware ) {
+out.println("    "+jclass.getSimpleName()+"* info ="); 
+out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+    }
+
+    if( marshallerAware ) {
+out.println("    info->beforeMarshall( wireFormat );");
+    }
+
+out.println("    "+baseClass+"::looseMarshal( wireFormat, dataStructure, dataOut );");
+out.println("");
+
+    generateLooseMarshalBody(out);
+
+    if( marshallerAware ) {
+out.println("    info->afterMarshall( wireFormat );");
+    }
+
+out.println("}");
+out.println("");
+}
+    
+    public void generateFactory(PrintWriter out) {
+		generateLicence(out);
+        
+out.println("#include <activemq/connector/openwire/marshal/V"+getOpenwireVersion()+"/MarshallerFactory.h>");
+
+    List list = new ArrayList(getConcreteClasses());
+    Collections.sort(list, new Comparator(){
+        public int compare(Object o1, Object o2) {
+            JClass c1 = (JClass) o1;
+            JClass c2 = (JClass) o2;
+            return c1.getSimpleName().compareTo(c2.getSimpleName());
+    }});
+    
+    for (Iterator iter = list.iterator(); iter.hasNext();) {
+        JClass jclass = (JClass) iter.next();
+out.println("#include <activemq/connector/openwire/marshal/v"+getOpenwireVersion()+"/"+jclass.getSimpleName()+"Marshaller.h>");
+    }        
+
+out.println("");
+out.println("/*");
+out.println(" *");
+out.println(" *  Command and marshalling code for OpenWire format for MarshallerFactory");
+out.println(" *");
+out.println(" *");
+out.println(" *  NOTE!: This file is autogenerated - 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(" */");
+out.println("");
+out.println("using namespace activemq;");
+out.println("using namespace activemq::connector;");
+out.println("using namespace activemq::connector::openwire;");
+out.println("using namespace activemq::connector::openwire::marshal;");
+out.println("using namespace activemq::connector::openwire::marshal::v"+getOpenwireVersion()+";");
+out.println("");
+out.println("///////////////////////////////////////////////////////////////////////////////");
+out.println("void MarshallerFactory::configure( OpenWireFormat* format ) {");
+
+    for (Iterator iter = list.iterator(); iter.hasNext();) {
+        JClass jclass = (JClass) iter.next();
+out.println("    format->addMarshaller( new "+jclass.getSimpleName()+"Marshaller());");
+}        
+
+out.println("}");
+out.println("");
+    }
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java?view=auto&rev=471943
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java Mon Nov  6 16:21:55 2006
@@ -0,0 +1,226 @@
+/**
+ *
+ * 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.openwire.tool;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+/**
+ *
+ * @version $Revision: 381410 $
+ */
+public class AmqCppMarshallingHeadersGenerator extends JavaMarshallingGenerator {
+
+	protected String targetDir="./src/main";
+
+    public Object run() {
+        filePostFix = getFilePostFix();
+        if (destDir == null) {
+            destDir = new File(targetDir+"/activemq/connector/openwire/marshal/v"+getOpenwireVersion());
+        }
+        return super.run();
+    }	   
+    
+    protected String getFilePostFix() {
+        return ".h";
+    }
+    
+    
+	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_CONNECTOR_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_"+className.toUpperCase()+"_H_");
+out.println("#define _ACTIVEMQ_CONNECTOR_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("");
+out.println("#include <activemq/connector/openwire/marshal/V"+getOpenwireVersion()+"/"+baseClass+".h>");
+out.println("");
+out.println("#include <activemq/io/DataInputStream.h>");
+out.println("#include <activemq/io/DataOutputStream.h>");
+out.println("#include <activemq/io/IOException.h>");
+out.println("#include <activemq/connector/openwire/commands/DataStructure.h>");
+out.println("#include <activemq/connector/openwire/util/BooleanStream.h>");
+out.println("");
+out.println("namespace activemq{");
+out.println("namespace connector{");
+out.println("namespace openwire{");
+out.println("namespace marshal{");
+out.println("namespace v"+getOpenwireVersion()+"{");
+out.println("");
+out.println("    /**");
+out.println("     * Marshalling code for Open Wire Format for "+className);
+out.println("     *");
+out.println("     *  NOTE!: This file is autogenerated - 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 "+className+" : public "+baseClass);
+out.println("    {");
+out.println("    public:");
+out.println("");
+out.println("        "+className+"() {};");
+out.println("        virtual ~"+className+"() {};");
+out.println("");
+out.println("        /**");
+out.println("         * Creates a new instance of this marshalable type.");
+out.println("         * @return new DataStructure object pointer caller owns it.");
+out.println("         */");
+out.println("        virtual DataStructure* createObject() const;");
+out.println("");
+out.println("        /**");
+out.println("         * Get the Data Structure Type that identifies this Marshaller");
+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("         * @param wireFormat - describs the wire format of the broker");
+out.println("         * @param o - Object to be un-marshaled");
+out.println("         * @param dataIn - BinaryReader that provides that data");
+out.println("         * @param bs - BooleanStream");
+out.println("         */"); 
+out.println("        virtual void tightUnmarshal( OpenWireFormat* wireFormat,"); 
+out.println("                                     commands::DataStructure* dataStructure,"); 
+out.println("                                     io::DataInputStream* dataIn,"); 
+out.println("                                     util::BooleanStream* bs ) throws( io::IOException );");
+out.println("");
+out.println("        /**");
+out.println("         * Write the booleans that this object uses to a BooleanStream");
+out.println("         * @param wireFormat - describis the wire format of the broker");
+out.println("         * @param o - Object to be marshaled");
+out.println("         * @param bs - BooleanStream");
+out.println("         * @returns int");
+out.println("         */");
+out.println("        virtual int tightMarshal1( OpenWireFormat* wireFormat,"); 
+out.println("                                   commands::DataStructure* dataStructure,"); 
+out.println("                                   BooleanStream* bs ) throws( io::IOException );");
+out.println("");
+out.println("        /**");
+out.println("         * Write a object instance to data output stream");
+out.println("         * @param wireFormat - describs the wire format of the broker");
+out.println("         * @param o - Object to be marshaled");
+out.println("         * @param dataOut - BinaryReader that provides that data sink");
+out.println("         * @param bs - BooleanStream");
+out.println("         */");
+out.println("        virtual void tightMarshal2( OpenWireFormat* wireFormat,"); 
+out.println("                                    commands::DataStructure* dataStructure,"); 
+out.println("                                    io::DataOutputStream* dataOut,"); 
+out.println("                                    BooleanStream* bs ) throws( io::IOException );");
+out.println("");
+out.println("        /**"); 
+out.println("         * Un-marshal an object instance from the data input stream");
+out.println("         * @param wireFormat - describs the wire format of the broker");
+out.println("         * @param o - Object to be marshaled");
+out.println("         * @param dataIn - BinaryReader that provides that data source");
+out.println("         */"); 
+out.println("        virtual void looseUnmarshal( OpenWireFormat* wireFormat,"); 
+out.println("                                     commands::DataStructure* dataStructure,"); 
+out.println("                                     io::DataInputStream* dataIn ) throws( io::IOException );");
+out.println("");
+out.println("        /**"); 
+out.println("         * Write a object instance to data output stream");
+out.println("         * @param wireFormat - describs the wire format of the broker");
+out.println("         * @param o - Object to be marshaled");
+out.println("         * @param dataOut - BinaryWriter that provides that data sink");
+out.println("         */");
+out.println("        virtual void looseMarshal( OpenWireFormat* wireFormat,"); 
+out.println("                                   commands::DataStructure* dataStructure,"); 
+out.println("                                   io::DataOutputStream* dataOut ) throws( io::IOException );");
+out.println(""); 
+out.println("    };");
+out.println("");
+out.println("}}}}}");
+out.println("");
+out.println("#endif /*_ACTIVEMQ_CONNECTOR_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_"+className.toUpperCase()+"_H_*/");
+out.println("");
+        }
+ 	
+    public void generateFactory(PrintWriter out) {
+		generateLicence(out);
+out.println("#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_MARSHALLERFACTORY_H_");
+out.println("#define _ACTIVEMQ_CONNECTOR_OPENWIRE_MARSAHAL_V"+getOpenwireVersion()+"_MARSHALLERFACTORY_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 <activemq/connector/openwire/OpenWireFormat.h>");
+out.println("");
+out.println("namespace activemq{");
+out.println("namespace connector{");
+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 autogenerated - 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("    {");
+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_CONNECTOR_OPENWIRE_MARSHAL_V"+getOpenwireVersion()+"_MARSHALLERFACTORY_H_*/");
+    }
+
+	public String getTargetDir() {
+		return targetDir;
+	}
+
+	public void setTargetDir(String targetDir) {
+		this.targetDir = targetDir;
+	}
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message