You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2006/11/16 01:16:23 UTC

svn commit: r475503 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts: AmqCppClassesGenerator.java AmqCppMarshallingClassesGenerator.java AmqCppMarshallingHeadersGenerator.java

Author: tabish
Date: Wed Nov 15 16:16:22 2006
New Revision: 475503

URL: http://svn.apache.org/viewvc?view=rev&rev=475503
Log:
Updates for planned Openwire Support

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

Modified: 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=diff&rev=475503&r1=475502&r2=475503
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppClassesGenerator.java Wed Nov 15 16:16:22 2006
@@ -53,7 +53,7 @@
         }
         else if( type.isArrayType() ) {
             if( name.equals( "byte[]" ) )
-                name = "char[]";
+                name = "unsigned char[]";
             
             JClass arrayClass = type.getArrayComponentType();
             
@@ -70,7 +70,7 @@
             return "DataStructure";
         }
         else if( name.equals("ByteSequence") ) {
-            return "std::vector<char>";
+            return "std::vector<unsigned char>";
         }
         else if( name.equals("boolean") ) {
             return "bool";
@@ -79,7 +79,7 @@
             return "long long";
         }
         else if( name.equals("byte") ) {
-            return "char";
+            return "unsigned char";
         }
         else if( !type.isPrimitiveType() ) {
             return name;
@@ -97,104 +97,15 @@
 
         if (name.equals("boolean")) {
             return "false";
-        } else if ( name.equals("String") ) {
+        } else if( name.equals("String") ) {
             return "\"\"";
-        } else if (!type.isPrimitiveType()) {
+        } 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");

Modified: 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=diff&rev=475503&r1=475502&r2=475503
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingClassesGenerator.java Wed Nov 15 16:16:22 2006
@@ -79,11 +79,11 @@
                 out.println("    info->" + setter + "( tightUnmarshalByteArray( dataIn, bs ) );");
             }
         }
-        else if (isThrowable(property.getType())) {
+        else if( isThrowable( property.getType() ) ) {
             out.println("    info->" + setter + "( dynamic_cast< " + nativeType + "* >(");
             out.println("        tightUnmarshalBrokerError( wireFormat, dataIn, bs ) ) );");
         }
-        else if (isCachedProperty(property)) {
+        else if( isCachedProperty(property) ) {
             out.println("    info->" + setter + "( dynamic_cast< " + nativeType + "* >(");
             out.println("        tightUnmarshalCachedObject( wireFormat, dataIn, bs ) ) );");
         }
@@ -223,12 +223,12 @@
             }
             else if (type.equals("byte[]") || type.equals("ByteSequence")) {
                 if (size != null) {
-                    out.println("    dataOut->write( " + getter + ", 0, " + size.asInt() + " );");
+                    out.println("    dataOut->write( &" + getter + "[0], " + size.asInt() + " );");
                 }
                 else {
                     out.println("    if( bs->readBoolean() ) {");
                     out.println("        dataOut->write( " + getter + ".size() );");
-                    out.println("        dataOut->write( (const unsigned char*)&(" + getter + "[0]), " + getter + ".size() );");
+                    out.println("        dataOut->write( &" + getter + "[0], " + getter + ".size() );");
                     out.println("    }");
                 }
             }
@@ -374,13 +374,13 @@
             }
             else if( type.equals("byte[]") || type.equals("ByteSequence") ) {
                 if(size != null) {
-                    out.println("    dataOut->write( " + getter + ", 0, " + size.asInt() + " );");
+                    out.println("    dataOut->write( &" + getter + "[0], " + size.asInt() + " );");
                 }
                 else {
                     out.println("    dataOut->write( " + getter + ".size() != 0 );");
                     out.println("    if( " + getter + ".size() != 0 ) {");
                     out.println("        dataOut->write( " + getter + ".size() );");
-                    out.println("        dataOut->write( (const unsigned char*)&(" + getter + "[0]), " + getter + ".size() );");
+                    out.println("        dataOut->write( &" + getter + "[0], " + getter + ".size() );");
                     out.println("    }");
                 }
             }

Modified: 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=diff&rev=475503&r1=475502&r2=475503
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/openwire-scripts/AmqCppMarshallingHeadersGenerator.java Wed Nov 15 16:16:22 2006
@@ -49,7 +49,7 @@
         }
         else if( type.isArrayType() ) {
             if( name.equals( "byte[]" ) )
-                name = "char[]";
+                name = "unsigned char[]";
             
             JClass arrayClass = type.getArrayComponentType();
             
@@ -75,7 +75,7 @@
             return "long long";
         }
         else if( name.equals("byte") ) {
-            return "char";
+            return "unsigned char";
         }
         else if( !type.isPrimitiveType() ) {
             return name;