axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From era...@apache.org
Subject svn commit: r799977 - in /webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba: idl/parser/ idl/types/ receivers/
Date Sun, 02 Aug 2009 03:58:01 GMT
Author: eranga
Date: Sun Aug  2 03:58:00 2009
New Revision: 799977

URL: http://svn.apache.org/viewvc?rev=799977&view=rev
Log:
const IDL data type support (Fix for AXIS2-4385)

Added:
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/ExpressionUtil.java
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ConstType.java
Modified:
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
    webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java

Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/ExpressionUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/ExpressionUtil.java?rev=799977&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/ExpressionUtil.java
(added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/ExpressionUtil.java
Sun Aug  2 03:58:00 2009
@@ -0,0 +1,508 @@
+/*
+ * 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.axis2.corba.idl.parser;
+
+import antlr.collections.AST;
+import org.apache.axis2.corba.exceptions.InvalidIDLException;
+import org.apache.axis2.corba.idl.types.*;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TCKind;
+
+import java.util.Map;
+
+public class ExpressionUtil {
+    public static Object eval(AST expressionNode, DataType returnType, IDLVisitor visitor)
throws InvalidIDLException {
+        Object value;
+        AST node1;
+        AST node2;
+        int expressionType = expressionNode.getType();
+        TypeCode typeCode = returnType.getTypeCode();
+        switch (expressionType) {
+
+            case IDLTokenTypes.PLUS:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = node2 == null? eval(node1, returnType, visitor)
+                        : add(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.MINUS:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = node2 == null? minus(eval(node1, returnType, visitor), typeCode)
+                        : subtract(eval(node1, returnType, visitor), eval(node2, returnType,
visitor), typeCode);
+                break;
+
+            case IDLTokenTypes.STAR:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = multiply(eval(node1, returnType, visitor), eval(node2, returnType,
visitor), typeCode);
+                break;
+
+            case IDLTokenTypes.DIV:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = div(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.MOD:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = mod(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.OR:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = or(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.AND:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = and(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.RSHIFT:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = rshift(eval(node1, returnType, visitor), eval(node2, returnType,
visitor), typeCode);
+                break;
+
+            case IDLTokenTypes.LSHIFT:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = lshift(eval(node1, returnType, visitor), eval(node2, returnType,
visitor), typeCode);
+                break;
+
+            case IDLTokenTypes.XOR:
+                node1 = expressionNode.getFirstChild();
+                node2 = node1.getNextSibling();
+                value = xor(eval(node1, returnType, visitor), eval(node2, returnType, visitor),
typeCode);
+                break;
+
+            case IDLTokenTypes.TILDE:
+                node1 = expressionNode.getFirstChild();
+                Object boolObj = eval(node1, returnType, visitor);
+                if (!(boolObj instanceof Boolean)) {
+                    throw new InvalidIDLException("A boolean value is expected after (~)
operator");
+                }
+                value = Boolean.valueOf(!((Boolean) boolObj).booleanValue());
+                break;
+
+            case IDLTokenTypes.INT:
+            case IDLTokenTypes.FLOAT:
+            case IDLTokenTypes.STRING_LITERAL:
+            case IDLTokenTypes.WIDE_STRING_LITERAL:
+            case IDLTokenTypes.CHAR_LITERAL:
+            case IDLTokenTypes.WIDE_CHAR_LITERAL:
+            case IDLTokenTypes.FIXED:
+                value = getValueObject(expressionNode.getText(), returnType);
+                break;
+
+            case IDLTokenTypes.LITERAL_TRUE:
+                value = Boolean.valueOf(true);
+                break;
+
+            case IDLTokenTypes.LITERAL_FALSE:
+                value = Boolean.valueOf(true);
+                break;
+
+            case IDLTokenTypes.IDENT:
+                value = getConstant(expressionNode.getText(), visitor);
+                break;
+            
+            case IDLTokenTypes.LPAREN:
+                value = eval(expressionNode.getFirstChild(), returnType, visitor);
+                break;
+
+            default:
+                throw new InvalidIDLException("Unsupported IDL token " + expressionNode);
+        }
+        return value;
+    }
+
+    private static Object add(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() + ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() + ((Long) o2).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(((Float) o1).floatValue() + ((Float) o2).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() + ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() + ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object minus(Object o, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(-((Integer) o).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(-((Long) o).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(-((Float) o).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (-((Short) o).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(- ((Double) o).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (- ((Byte) o).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object subtract(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() - ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() - ((Long) o2).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(((Float) o1).floatValue() - ((Float) o2).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() - ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(((Double) o1).doubleValue() - ((Double) o2).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() - ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object multiply(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() * ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() * ((Long) o2).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(((Float) o1).floatValue() * ((Float) o2).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() * ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(((Double) o1).doubleValue() * ((Double) o2).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() * ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object div(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() / ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() / ((Long) o2).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(((Float) o1).floatValue() / ((Float) o2).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() / ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() / ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object rshift(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() >> ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() >> ((Long) o2).longValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() >> ((Short)
o2).shortValue()));
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() >> ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object lshift(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() << ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() << ((Long) o2).longValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() << ((Short)
o2).shortValue()));
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() << ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object xor(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() ^ ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() ^ ((Long) o2).longValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() ^ ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() ^ ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object mod(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() % ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() % ((Long) o2).longValue());
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(((Float) o1).floatValue() % ((Float) o2).floatValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() % ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(((Double) o1).doubleValue() % ((Double) o2).doubleValue());
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() % ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object or(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() | ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() | ((Long) o2).longValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() | ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() | ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object and(Object o1, Object o2, TypeCode returnType) throws InvalidIDLException
{
+        TCKind kind = returnType.kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(((Integer) o1).intValue() & ((Integer) o2).intValue());
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(((Long) o1).longValue() & ((Long) o2).longValue());
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short((short) (((Short) o1).shortValue() & ((Short) o2).shortValue()));
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte((byte) (((Byte) o1).byteValue() & ((Byte) o2).byteValue()));
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token");
+        }
+        return valueObj;
+    }
+
+    private static Object getValueObject(String value, DataType type) throws InvalidIDLException
{
+        TCKind kind = type.getTypeCode().kind();
+        Object valueObj;
+        switch (kind.value()) {
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+                valueObj = new Integer(value);
+                break;
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+                valueObj = new Long(value);
+                break;
+            case TCKind._tk_float:
+                valueObj = new Float(value);
+                break;
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+                valueObj = new Short(value);
+                break;
+            case TCKind._tk_char:
+            case TCKind._tk_wchar:
+                valueObj = new Character(value.charAt(0));
+                break;
+            case TCKind._tk_double:
+                valueObj = new Double(value);
+                break;
+            case TCKind._tk_octet:
+                valueObj = new Byte(value);
+                break;
+            case TCKind._tk_string:
+            case TCKind._tk_wstring:
+                valueObj = value;
+                break;
+            case TCKind._tk_alias:
+                Typedef typedef = (Typedef) type;
+                valueObj = getValueObject(value, typedef.getDataType());
+                break;
+            default:
+                throw new InvalidIDLException("Unsupported IDL token ");
+        }
+        return valueObj;
+    }
+
+    private static Object getConstant(String expressionName, IDLVisitor visitor) throws InvalidIDLException
{
+        Object value;
+        DataType dataType = visitor.getDataType(expressionName);
+        if (dataType != null && dataType instanceof ConstType) {
+            ConstType constType = (ConstType) dataType;
+            value = constType.getValue();
+        } else {
+            throw new InvalidIDLException("Constant " + expressionName + " not found.");
+        }
+        return value;
+    }
+}
+

Modified: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java?rev=799977&r1=799976&r2=799977&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
(original)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
Sun Aug  2 03:58:00 2009
@@ -20,22 +20,7 @@
 package org.apache.axis2.corba.idl.parser;
 
 import antlr.collections.AST;
-import org.apache.axis2.corba.idl.types.ArrayType;
-import org.apache.axis2.corba.idl.types.CompositeDataType;
-import org.apache.axis2.corba.idl.types.DataType;
-import org.apache.axis2.corba.idl.types.EnumType;
-import org.apache.axis2.corba.idl.types.ExceptionType;
-import org.apache.axis2.corba.idl.types.IDL;
-import org.apache.axis2.corba.idl.types.Interface;
-import org.apache.axis2.corba.idl.types.Member;
-import org.apache.axis2.corba.idl.types.Operation;
-import org.apache.axis2.corba.idl.types.PrimitiveDataType;
-import org.apache.axis2.corba.idl.types.SequenceType;
-import org.apache.axis2.corba.idl.types.Struct;
-import org.apache.axis2.corba.idl.types.Typedef;
-import org.apache.axis2.corba.idl.types.UnionMember;
-import org.apache.axis2.corba.idl.types.UnionType;
-import org.apache.axis2.corba.idl.types.ValueType;
+import org.apache.axis2.corba.idl.types.*;
 import org.apache.axis2.corba.exceptions.InvalidIDLException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -112,6 +97,11 @@
                     break;
                 }
 
+                case IDLTokenTypes.LITERAL_const: {
+                    idl.addType(visitConst(node));
+                    break;
+                }
+
                 default: {
                     throw new InvalidIDLException("Unsupported IDL token " + node);
                 }
@@ -363,8 +353,7 @@
             return typedef;
         }
 
-        DataType dataType = null;
-        Map compositeDataTypes = idl.getCompositeDataTypes();
+        DataType dataType;
 
         String typeName;
         if (typeNode.getType() == IDLTokenTypes.LITERAL_unsigned) {
@@ -377,9 +366,7 @@
                 typeName = "ushort";
             } else if (nextNode.getType() == IDLTokenTypes.LITERAL_long) {
                 AST nextToLong = nextNode.getNextSibling();
-                if (nextToLong == null) {
-                    throw new InvalidIDLException("an identifier is required after the 'long'
keyword");
-                } else if (nextToLong.getType() == IDLTokenTypes.LITERAL_long) {
+                if (nextToLong != null && nextToLong.getType() == IDLTokenTypes.LITERAL_long)
{
                     typeNode.setNextSibling(nextToLong.getNextSibling());
                     typeNode.setFirstChild(nextToLong.getFirstChild());
                     typeName = "ulonglong";
@@ -393,9 +380,7 @@
             }
         } else if (typeNode.getType() == IDLTokenTypes.LITERAL_long) {
             AST nextToLong = typeNode.getNextSibling();
-            if (nextToLong == null) {
-                throw new InvalidIDLException("an identifier is required after the 'long'
keyword");
-            } else if (nextToLong.getType() == IDLTokenTypes.LITERAL_long) {
+            if (nextToLong != null && nextToLong.getType() == IDLTokenTypes.LITERAL_long)
{
                 typeNode.setNextSibling(nextToLong.getNextSibling());
                 typeNode.setFirstChild(nextToLong.getFirstChild());
                 typeName = "longlong";
@@ -407,7 +392,8 @@
         }
 
 
-        if (compositeDataTypes!=null) {
+       /*   Map compositeDataTypes = idl.getCompositeDataTypes();
+            if (compositeDataTypes!=null) {
             if (!module.equals("")) {
                 if (!typeName.startsWith(module)) {
                     dataType = (DataType) idl.getCompositeDataTypes().get(module + typeName);
@@ -424,11 +410,59 @@
                 dataType = (DataType) idl.getCompositeDataTypes().get(typeName);
         }
 
-        if (dataType==null)
+
+        if (dataType == null)
             dataType = PrimitiveDataType.getPrimitiveDataType(typeName);
 
         if (dataType == null)
             throw new InvalidIDLException("Invalid data type: " + typeName);
+        }
+
+        */
+        dataType = getDataType(typeName);
+
+        return dataType;
+    }
+
+    DataType getDataType(String typeName) throws InvalidIDLException {
+        DataType dataType = null;
+        Map compositeDataTypes = idl.getCompositeDataTypes();
+
+        if (compositeDataTypes != null) {
+            if (moduleForInnerTypes!=null) {
+                if (!typeName.startsWith(module)) {
+                    dataType = (DataType) compositeDataTypes.get(moduleForInnerTypes + typeName);
+                }
+            }
+
+            String tempModule = module;
+            int modSepLen = CompositeDataType.MODULE_SEPERATOR.length();
+            while (dataType == null) {
+                dataType = (DataType) idl.getCompositeDataTypes().get(tempModule + typeName);
+                if (dataType == null && !tempModule.isEmpty()) {
+                    if (tempModule.endsWith(CompositeDataType.MODULE_SEPERATOR)) {
+                        tempModule = tempModule.substring(0, tempModule.length() - modSepLen);
   
+                    }
+                    int modSepPos = tempModule.lastIndexOf(CompositeDataType.MODULE_SEPERATOR);
+                    if (modSepPos < 0) {
+                        tempModule = "";
+                    } else {
+                        tempModule = tempModule.substring(0, modSepPos + modSepLen);
+                    }
+                } else {
+                    break;
+                }
+            }
+        }
+
+        if (dataType == null) {
+            dataType = PrimitiveDataType.getPrimitiveDataType(typeName);
+        }
+
+        if (dataType == null) {
+            throw new InvalidIDLException("Invalid data type: " + typeName);
+        }
+
         return dataType;
     }
 
@@ -471,7 +505,8 @@
         unionType.setModule(module);
         unionType.setName(unName);
         AST switchTypeNode = unNode.getNextSibling();
-        unionType.setDiscriminatorType(findDataType(switchTypeNode, unName));
+        DataType discrimType = findDataType(switchTypeNode, unName);
+        unionType.setDiscriminatorType(discrimType);
         AST caseOrDefaultNode = switchTypeNode.getNextSibling();
         while (caseOrDefaultNode != null) {
             UnionMember unionMember = new UnionMember();
@@ -482,7 +517,17 @@
             } else {
                 unionMember.setDefault(false);
                 AST caseValueNode = caseOrDefaultNode.getFirstChild();
-                unionMember.setDiscriminatorValue(caseValueNode.getText());
+                String caseNodeText = caseValueNode.getText();
+                if (!(discrimType instanceof EnumType) && IDLTokenTypes.IDENT ==
caseValueNode.getType()) {
+                    //Get const value
+                    DataType constType = getDataType(caseNodeText);
+                    if (constType instanceof ConstType) {
+                        caseNodeText = ((ConstType) constType).getValue().toString();
+                    } else {
+                        throw new InvalidIDLException(caseNodeText + "is not a constant name");
+                    }
+                }
+                unionMember.setDiscriminatorValue(caseNodeText);
                 typeNode = caseValueNode.getNextSibling();
             }
 
@@ -576,7 +621,25 @@
 
         AST countNode = typeNode.getNextSibling();
         if (countNode!=null) {
-            sequenceType.setElementCount(Integer.parseInt(countNode.getText()));
+            int count;
+            if (IDLTokenTypes.IDENT == countNode.getType()) {
+                //Get const value
+                String constName = countNode.getText();
+                DataType constType = getDataType(constName);
+                if (constType instanceof ConstType) {
+                    Object countValue = ((ConstType) constType).getValue();
+                    if (countValue instanceof Integer) {
+                        count = ((Integer) countValue).intValue();
+                    } else {
+                        throw new InvalidIDLException(constName + "is not a long");
+                    }
+                } else {
+                    throw new InvalidIDLException(constName + "is not a constant name");
+                }
+            } else {
+                count = Integer.parseInt(countNode.getText());
+            }
+            sequenceType.setElementCount(count);
             //sequenceType.setBounded(true);
         } else {
             sequenceType.setElementCount(0);
@@ -585,4 +648,27 @@
         return sequenceType;
     }
 
+    private ConstType visitConst(AST node) throws InvalidIDLException {
+        AST constTypeNode = node.getFirstChild();
+        AST constNameNode = constTypeNode.getNextSibling();
+        while (constNameNode != null && IDLTokenTypes.IDENT != constNameNode.getType())
{
+            constNameNode = constNameNode.getNextSibling();    
+        }
+
+        if (constNameNode == null) {
+            throw new InvalidIDLException("Constant name not found");
+        }
+
+        String constName = constNameNode.toString();
+        ConstType constType = new ConstType();
+        constType.setModule(module);
+        constType.setName(constName);
+        DataType type = findDataType(constTypeNode, constName);
+        constType.setDataType(type);
+        AST constValueNode = constNameNode.getNextSibling();
+        constType.setValue(ExpressionUtil.eval(constValueNode, type, this));
+        //System.out.println(constType.getValue());
+        return constType;
+    }
+
 }

Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ConstType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ConstType.java?rev=799977&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ConstType.java
(added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ConstType.java
Sun Aug  2 03:58:00 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+
+public class ConstType extends CompositeDataType {
+    private DataType dataType;
+    private Object value;
+
+    protected TypeCode generateTypeCode() {
+        return null;
+    }
+
+    public DataType getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java?rev=799977&r1=799976&r2=799977&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
(original)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
Sun Aug  2 03:58:00 2009
@@ -75,7 +75,11 @@
     }
 
     public static PrimitiveDataType getPrimitiveDataType(String typeName) {
-        return new PrimitiveDataType(getTypeCode(typeName));
+        TypeCode typeCode = getTypeCode(typeName);
+        if (typeCode == null) {
+            return null;
+        }
+        return new PrimitiveDataType(typeCode);
     }
 
     public PrimitiveDataType(TypeCode typeCode){

Modified: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java?rev=799977&r1=799976&r2=799977&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java
Sun Aug  2 03:58:00 2009
@@ -42,6 +42,11 @@
 import java.util.HashMap;
 import java.util.Map;
 
+/**
+ * This is takes care of the IN-OUT sync MEP in the server side
+ *
+ * @deprecated no longer needed, going away after 1.3
+ */
 public class CorbaInOutAsyncMessageReceiver extends AbstractInOutAsyncMessageReceiver implements
CorbaConstants {
 
     private static Log log = LogFactory.getLog(CorbaInOutAsyncMessageReceiver.class);



Mime
View raw message