activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r503349 - in /activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts: AmqCppClassesGenerator.java AmqCppHeadersGenerator.java AmqCppMarshallingClassesGenerator.java AmqCppMarshallingHeadersGenerator.java
Date Sun, 04 Feb 2007 03:13:34 GMT
Author: tabish
Date: Sat Feb  3 19:13:34 2007
New Revision: 503349

URL: http://svn.apache.org/viewvc?view=rev&rev=503349
Log:
http://issues.apache.org/activemq/browse/AMQCPP-30

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
    activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
    activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
    activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java

Modified: activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java?view=diff&rev=503349&r1=503348&r2=503349
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java
Sat Feb  3 19:13:34 2007
@@ -46,6 +46,24 @@
         return ".cpp";
     }
 
+    protected String getProperBaseClassName( String className, String baseClass ) {
+
+        if( baseClass == null || className == null ) {
+            return null;
+        }
+        
+        // The C++ BaseCommand class is a template, which requires either
+        // transport::Command, or transport::Response.
+        if( className.equals( "Response" ) ) {
+            return "BaseCommand<transport::Response>"; 
+        } else if( baseClass.equals( "BaseCommand" ) ) {
+            return "BaseCommand<transport::Command>";
+        }
+        
+        // No change.
+        return baseClass;
+    }
+    
     public String toCppType(JClass type) {
         String name = type.getSimpleName();
         if (name.equals("String")) {
@@ -211,7 +229,7 @@
 
         if( baseClass != null ) {
 out.println("    // Copy the data of the base class or classes");
-out.println("    "+baseClass+"::copyDataStructure( src );");
+out.println("    "+getProperBaseClassName( className, baseClass )+"::copyDataStructure( src
);");
 out.println("");
         }
         
@@ -289,6 +307,17 @@
 
            
 out.println("");
+
+    if( property.getType().isPrimitiveType() ) {
+
+out.println("////////////////////////////////////////////////////////////////////////////////");
+out.println(type+" "+className+"::"+getter+"() const {");
+out.println("    return "+parameterName+";");
+out.println("}");
+out.println("");
+
+    } else {
+        
 out.println("////////////////////////////////////////////////////////////////////////////////");
 out.println("const "+type+" "+className+"::"+getter+"() const {");
 out.println("    return "+parameterName+";");
@@ -299,6 +328,9 @@
 out.println("    return "+parameterName+";");
 out.println("}");
 out.println("");
+
+    }
+
 out.println("////////////////////////////////////////////////////////////////////////////////");
 out.println("void " + className + "::" + setter+"(" + constNess + type+ " " + parameterName
+" ) {");
 out.println("    this->"+parameterName+" = "+parameterName+";");

Modified: activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java?view=diff&rev=503349&r1=503348&r2=503349
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppHeadersGenerator.java
Sat Feb  3 19:13:34 2007
@@ -34,9 +34,9 @@
     protected String getFilePostFix() {
         return ".h";
     }
-    
+
 	protected void generateFile(PrintWriter out) {
-		generateLicence(out);		
+		generateLicence(out);
 
 out.println("");
 out.println("#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_"+className.toUpperCase()+"_H_");
@@ -89,7 +89,7 @@
 out.println("     *         in the activemq-openwire-generator module");
 out.println("     *");
 out.println("     */");
-out.println("    class "+className+" : public "+baseClass);
+out.println("    class "+className+" : public "+getProperBaseClassName( className, baseClass
) );
 out.println("    {");
 out.println("    protected:");
 out.println("");
@@ -164,11 +164,16 @@
             	type = type + "&";
                 constness = "const ";
             }
-            
-            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("");
+
+            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("");
         }
 
 out.println("    };");

Modified: activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java?view=diff&rev=503349&r1=503348&r2=503349
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java
Sat Feb  3 19:13:34 2007
@@ -39,6 +39,15 @@
         return ".cpp";
     }
 
+    protected String getProperClassName( String className ) {
+
+        if( className.equals( "BaseCommand") ) {
+            return "transport::Command";
+        }
+        
+        return className;
+    }
+    
     //////////////////////////////////////////////////////////////////////////////////////
     // This section is for the tight wire format encoding generator
     //////////////////////////////////////////////////////////////////////////////////////
@@ -457,8 +466,9 @@
     boolean marshallerAware = isMarshallerAware();
     if( !properties.isEmpty() || marshallerAware ) {
 
-out.println("    "+jclass.getSimpleName()+"* info ="); 
-out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+        String properClassName = getProperClassName( jclass.getSimpleName() );
+out.println("    "+properClassName+"* info ="); 
+out.println("        dynamic_cast<"+properClassName+"*>( dataStructure );");
     }
 
     if( marshallerAware ) {
@@ -480,8 +490,9 @@
 out.println("");
 
     if( !properties.isEmpty()  || marshallerAware ) { 
-out.println("    "+jclass.getSimpleName()+"* info ="); 
-out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+        String properClassName = getProperClassName( jclass.getSimpleName() );
+out.println("    "+properClassName+"* info ="); 
+out.println("        dynamic_cast<"+properClassName+"*>( dataStructure );");
 out.println("");
     }
         
@@ -504,8 +515,9 @@
 out.println("");
 
     if( !properties.isEmpty() || marshallerAware ) {
-out.println("    "+jclass.getSimpleName()+"* info ="); 
-out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+        String properClassName = getProperClassName( jclass.getSimpleName() );
+out.println("    "+properClassName+"* info ="); 
+out.println("        dynamic_cast<"+properClassName+"*>( dataStructure );");
     }
 
     generateTightMarshal2Body(out);
@@ -522,8 +534,9 @@
 out.println("    "+baseClass+"::looseUnmarshal( wireFormat, dataStructure, dataIn );");
  
     if( !properties.isEmpty() || marshallerAware ) {
-out.println("    "+jclass.getSimpleName()+"* info = ");
-out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+        String properClassName = getProperClassName( jclass.getSimpleName() );
+out.println("    "+properClassName+"* info ="); 
+out.println("        dynamic_cast<"+properClassName+"*>( dataStructure );");
     }
 
     if( marshallerAware ) {
@@ -543,8 +556,9 @@
 out.println("");
 
     if( !properties.isEmpty() || marshallerAware ) {
-out.println("    "+jclass.getSimpleName()+"* info ="); 
-out.println("        dynamic_cast<"+jclass.getSimpleName()+"*>( dataStructure );");
+        String properClassName = getProperClassName( jclass.getSimpleName() );
+out.println("    "+properClassName+"* info ="); 
+out.println("        dynamic_cast<"+properClassName+"*>( dataStructure );");
     }
 
     if( marshallerAware ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java?view=diff&rev=503349&r1=503348&r2=503349
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java
Sat Feb  3 19:13:34 2007
@@ -151,6 +151,9 @@
 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("         * @return new DataStructure object pointer caller owns it.");
@@ -163,6 +166,7 @@
 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");



Mime
View raw message