You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by mv...@apache.org on 2006/11/28 15:42:28 UTC

svn commit: r480098 [2/4] - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/processors/idl/ test/java/org/apache/yoko/tools/processors/ test/resources/idl/

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java Tue Nov 28 07:42:24 2006
@@ -35,48 +35,94 @@
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class StructVisitor extends TypesVisitorBase {
+public class StructVisitor extends VisitorBase {
     
-    public StructVisitor(XmlSchemaCollection xmlSchemas,
+    public StructVisitor(Scope scope,
+                         XmlSchemaCollection xmlSchemas,
                          XmlSchema xmlSchema,
                          TypeMappingType typeMappingType) {
-        super(xmlSchemas, xmlSchema, typeMappingType);
+        super(scope, xmlSchemas, xmlSchema, typeMappingType);
     }
 
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_struct) {
+            return true;
+        }
+        return false;
+    }
+    
     public void visit(AST node) {
-        AST structNode = node.getFirstChild();
+        // <struct_type> ::= "struct" <identifier> "{" <member_list> "}"
+        // <member_list> ::= <member>+
+        // <member> ::= <type_spec> <declarators> ";"
+
         
+        AST identifierNode = node.getFirstChild();
+        Scope structScope = new Scope(getScope(), identifierNode);        
+
         // xmlschema:struct
-        String structName = structNode.toString();
         XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema);
-        complexType.setName(structName);
+        complexType.setName(structScope.toString());
         XmlSchemaSequence sequence = new XmlSchemaSequence();
         complexType.setParticle(sequence);
 
         
         // corba:struct
         Struct struct = new Struct();
-        struct.setQName(new QName(typeMap.getTargetNamespace(), structName));
+        struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
         struct.setType(complexType.getQName());
         struct.setRepositoryID(CorbaConstants.REPO_STRING
-                               + structName
+                               + structScope.toIDLRepositoryID()
                                + CorbaConstants.IDL_VERSION);
 
         
         // struct members
-        AST memberTypeNode = structNode.getNextSibling();
+        AST memberTypeNode = identifierNode.getNextSibling();
         while (memberTypeNode != null) {
             AST memberNode = memberTypeNode.getNextSibling();
-
+            
+            XmlSchemaType schemaType = null;
+            CorbaTypeImpl corbaType = null;
+            try {
+                TypesVisitor visitor = new TypesVisitor(structScope, 
+                                                        schemas,
+                                                        schema,
+                                                        typeMap,
+                                                        null);
+                visitor.visit(memberTypeNode);
+                
+                schemaType = visitor.getSchemaType();
+                corbaType = visitor.getCorbaType();
+                
+            } catch (Exception ex) {
+                System.out.println(ex.getMessage());
+                System.exit(1);
+            }
+
+            // needed for anonymous arrays in structs 
+            if (ArrayVisitor.accept(memberNode)) {
+                Scope anonScope = new Scope(structScope,
+                                            TypesUtils.getPrimitiveCorbaTypeNameNode(memberTypeNode));
+                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
+                                                             schemas,
+                                                             schema,
+                                                             typeMap,
+                                                             schemaType,
+                                                             corbaType,
+                                                             null);
+                arrayVisitor.visit(memberNode);
+                schemaType = arrayVisitor.getSchemaType();
+                corbaType = arrayVisitor.getCorbaType();
+            }
+            
             // xmlschema:member
             XmlSchemaElement member = new XmlSchemaElement();
             String memberName = memberNode.toString();
             member.setName(memberName);
-            // type
-            XmlSchemaType type = TypesUtils.findType(schemas, schema, memberTypeNode);
-            member.setSchemaType(type);
-            member.setSchemaTypeName(type.getQName());
+            member.setSchemaType(schemaType);
+            member.setSchemaTypeName(schemaType.getQName());
 
             sequence.getItems().add(member);
 
@@ -84,22 +130,24 @@
             // corba:member
             MemberType memberType = new MemberType();
             memberType.setName(memberName);
-            QName idlType = TypesUtils.findCorbaType(typeMap, type.getQName()).getQName();
-            memberType.setIdltype(idlType);
+            memberType.setIdltype(corbaType.getQName());
             struct.getMember().add(memberType);
-            
-            
+
             memberTypeNode = memberNode.getNextSibling();
         }
 
+        // declaration phase
+        XmlSchemaType schemaType = complexType;
+        CorbaTypeImpl corbaType = struct;
+        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(structScope,
+                                                                    schemas,
+                                                                    schema,
+                                                                    typeMap,
+                                                                    schemaType,
+                                                                    corbaType);
+        declaratorVisitor.visit(identifierNode);
 
-        // add struct to schema
-        schema.getItems().add(complexType);
-        schema.addType(complexType);
-
-        // add struct to corba typemap
-        typeMap.getStructOrExceptionOrUnion().add(struct);
-        
+        // REVISIT: are there assignment needed?
         setSchemaType(complexType);
         setCorbaType(struct);
     }

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java Tue Nov 28 07:42:24 2006
@@ -31,234 +31,141 @@
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
 import org.apache.ws.commons.schema.XmlSchemaType;
-import org.apache.yoko.wsdl.CorbaConstants;
-
-public class TypedefVisitor extends TypesVisitorBase {
+import org.apache.ws.commons.schema.constants.Constants;
 
-    private static final int SEQUENCE = -1;
-    private static final int STRING =   -2;
-    private static final int WSTRING =  -3;
-    private static final int FIXED =    -4;
-    private static final int STRUCT =   -5;
-    private static final int UNION =    -6;
-    private static final int ENUM =     -7;
+import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
 
+public class TypedefVisitor extends VisitorBase {
     
-    public TypedefVisitor(XmlSchemaCollection xmlSchemas,
+    public TypedefVisitor(Scope scope,
+                          XmlSchemaCollection xmlSchemas,
                           XmlSchema xmlSchema,
                           TypeMappingType typeMappingType) {
-        super(xmlSchemas, xmlSchema, typeMappingType);
+        super(scope, xmlSchemas, xmlSchema, typeMappingType);
     }
     
-    public void visit(AST typedefNode) {
-        // "typedef" <type_declarator>
-        // <type_declarator> ::= <type_spec> <declarators>
-        // <type_spec> ::= <simple_type_spec>
-        //               | <constr_type_spec>
-        // <simple_type_spec> ::= <base_type_spec>
-        //                      | <template_type_spec> 
-        //                      | <scoped_name>
-        // <base_type_spec> ::= ... omitted (integer, char, octect, etc)
-        // <template_type_spec> ::= <sequence_type>
-        //                        | <string_type>
-        //                        | <wstring_type>
-        //                        | <fixed_pt_type>
-        // <constr_type_spec> ::= <struct_type>
-        //                      | <union_type>
-        //                      | <enum_type>
-        // <declarators> ::= <declarator> {"," <declarator>}*
-        // <declarator> ::= <simple_declarator>
-        //                | <complex_declarator>
-        // <simple_declarator> ::= <identifier>
-        // <complex_declarator> ::= <array_declarator>
-        // <array_declarator> ::= <identifier> <fixed_array_size>+
-        // <fixed_array_size> ::= "[" <positive_int_const> "]"
-
-        //AST typeDeclaratorNode = typedefNode.getFirstChild();
-
-        TypesVisitorBase visitor = null;
-        int type = getType(typedefNode);
-        switch (type) {
-        case SEQUENCE: {
-            visitor = new ArrayVisitor(schemas, schema, typeMap);
-            visitor.visit(typedefNode);
-            break;
-        }
-        case STRING:
-        case WSTRING: {
-            visitor = new StringVisitor(schemas, schema, typeMap);
-            visitor.visit(typedefNode);
-            break;
-        }
-        case FIXED: {
-            visitor = new FixedVisitor(schemas, schema, typeMap);
-            visitor.visit(typedefNode);
-            break;
-        }
-        case STRUCT: {
-            visitor = new StructVisitor(schemas, schema, typeMap);
-            AST structNode = typedefNode.getFirstChild(); 
-            visitor.visit(structNode);
-            visitAlias(typedefNode);
-            break;
-        }
-        case ENUM: {
-            visitor = new EnumVisitor(schemas, schema, typeMap);
-            visitor.visit(typedefNode.getFirstChild());
-            visitAlias(typedefNode);
-            break;
-        }
-        case UNION: {
-            visitor = new UnionVisitor(schemas, schema, typeMap);
-            visitor.visit(typedefNode.getFirstChild());
-            visitAlias(typedefNode);
-            break;    
-        }
-        default:
-            visitAlias(typedefNode);
-            break;
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
+            return true;
         }
+        return false;
     }
     
-    private int getType(AST node) {
-        int result;
-        if (isSequence(node)) {
-            result = SEQUENCE;
-        } else if (isString(node)) {
-            result = STRING;
-        } else if (isWString(node)) {
-            result = WSTRING;
-        } else if (isFixed(node)) {
-            result = FIXED;
-        } else if (isStruct(node)) {
-            result = STRUCT;
-        } else if (isEnum(node)) {
-            result = ENUM;
-        } else if (isUnion(node)) {
-            result = UNION;
-        } else {
-            result = node.getType();
-        }
-        return result;
-    }
+    public void visit(AST typedefNode) {
+        // "typedef" <type_declarator>
+        // <type_declarator> ::= <type_spec> <declarators>
 
-    private boolean isSequence(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_sequence) {                
-                result = true;
-            }
-        }
-        return result;
-    }
+        AST typeDeclaratorNode = typedefNode.getFirstChild();
+        AST identifierNode = TypesUtils.getPrimitiveCorbaTypeNameNode(typeDeclaratorNode);
+        
+        TypesVisitor typesVisitor = new TypesVisitor(getScope(), schemas, schema, typeMap, identifierNode);
+        typesVisitor.visit(typeDeclaratorNode);
 
-    private boolean isString(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_string) {                
-                result = true;
-            }
-        }
-        return result;
-    }
+        XmlSchemaType schemaType = typesVisitor.getSchemaType();
+        CorbaTypeImpl corbaType = typesVisitor.getCorbaType();
+        
+        Scope typedefScope = new Scope(getScope(), identifierNode);
+        
+        if (SequenceVisitor.accept(typeDeclaratorNode)
+            || FixedVisitor.accept(typeDeclaratorNode)) {
+            // Handle cases "typedef sequence"
+            //              "typedef fixed"
+            DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
+                                                                        schemas,
+                                                                        schema,
+                                                                        typeMap,
+                                                                        schemaType,
+                                                                        corbaType);
+            declaratorVisitor.visit(identifierNode);
+
+        } else if (StringVisitor.accept(typeDeclaratorNode)) {
+            // Handle cases "typedef string"
+            //              "typedef wstring"
+
+            if (StringVisitor.isBounded(typeDeclaratorNode)) {
+                DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
+                                                                            schemas,
+                                                                            schema,
+                                                                            typeMap,
+                                                                            schemaType,
+                                                                            corbaType);
+                declaratorVisitor.visit(identifierNode);
+  
+            } else {
+                Alias corbaString = new Alias();
+                if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
+                    corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
+                } else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring) {
+                    corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
+                } else { 
+                    // should never get here
+                    throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid node: "
+                                               + typeDeclaratorNode.toString());
+                }
+                corbaString.setQName(new QName(typeMap.getTargetNamespace(), typedefScope.toString()));
+                corbaString.setType(Constants.XSD_STRING);
+                corbaString.setRepositoryID(CorbaConstants.REPO_STRING
+                                            + typedefScope.toIDLRepositoryID()
+                                            + CorbaConstants.IDL_VERSION);
 
-    private boolean isWString(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_wstring) {                
-                result = true;
+                typeMap.getStructOrExceptionOrUnion().add(corbaString);
+                
             }
-        }
-        return result;
-    }
 
-    private boolean isFixed(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_fixed) {                
-                result = true;
-            }
-        }
-        return result;
-    }
+        } else {
+            // typedef used to define an alias
+            
+            // if declaring an array, do not generate aliases
+            if (!ArrayVisitor.accept(identifierNode)) {
+                generateAlias(identifierNode,
+                              schemaType,
+                              corbaType);
 
-    private boolean isStruct(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_struct) {                
-                result = true;
-            }
-        }
-        return result;        
-    }
-    
-    private boolean isEnum(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_enum) {                
-                result = true;
-            }
-        }
-        return result;                
-    }
-    
-    private boolean isUnion(AST node) {
-        boolean result = false;
-        if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_union) {                
-                result = true;
+                schemaType = getSchemaType();
+                corbaType = getCorbaType();
             }
+            
+            DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
+                                                                        schemas,
+                                                                        schema,
+                                                                        typeMap,
+                                                                        schemaType,
+                                                                        corbaType);
+            declaratorVisitor.visit(identifierNode);
+        
         }
-        return result;                
+
+
+        setSchemaType(schemaType);
+        setCorbaType(corbaType);
     }
     
-    private void visitAlias(AST typedefNode) {
-        AST typeSpecNode = typedefNode.getFirstChild();
-        
-        // perhaps getPrimitiveCorbaTypeNameNode is a misnomer
-        AST typeNameNode = TypesUtils.getPrimitiveCorbaTypeNameNode(typeSpecNode); 
-
-        XmlSchemaType type = null;
-        switch (typeSpecNode.getType()) {
-        case IDLTokenTypes.LITERAL_struct:
-        case IDLTokenTypes.LITERAL_enum:
-        case IDLTokenTypes.LITERAL_union:
-            type = TypesUtils.findType(schemas, schema, typeSpecNode.getFirstChild());
-            break;
-        default:
-            type = TypesUtils.findType(schemas, schema, typeSpecNode);
-            break;
-        }
-        
+    private void generateAlias(AST identifierNode,
+                               XmlSchemaType schemaType,
+                               CorbaTypeImpl corbaType) {
         // xmlschema:simpleType
         XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
-        simpleType.setName(typeNameNode.toString());
+        Scope scopedName = new Scope(getScope(), identifierNode);
+        simpleType.setName(scopedName.toString());
         XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
-        restriction.setBaseTypeName(type.getQName());
+        restriction.setBaseTypeName(schemaType.getQName());
         simpleType.setContent(restriction);
         
         // add xmlschema:simpleType
-        getSchema().getItems().add(simpleType);
-        getSchema().addType(simpleType);
-        
+        setSchemaType(simpleType);
+
         
         // corba:alias
         Alias alias = new Alias();
-        alias.setQName(new QName(typeMap.getTargetNamespace(), typeNameNode.toString()));
-        alias.setBasetype(TypesUtils.findCorbaType(typeMap, type.getQName()).getQName());
-        alias.setType(type.getQName());
+        alias.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
+        alias.setBasetype(corbaType.getQName());
+        alias.setType(schemaType.getQName());
         alias.setRepositoryID(CorbaConstants.REPO_STRING
-                              + typeNameNode.toString()
+                              + scopedName.toIDLRepositoryID()
                               + CorbaConstants.IDL_VERSION);
         
         // add corba:alias
-        typeMap.getStructOrExceptionOrUnion().add(alias);
+        setCorbaType(alias);
     }
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java Tue Nov 28 07:42:24 2006
@@ -19,72 +19,18 @@
 
 package org.apache.yoko.tools.processors.idl;
 
-import java.util.Iterator;
-
 import javax.xml.namespace.QName;
 
 import antlr.collections.AST;
 
-import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
-
 import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-//import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
-//import org.apache.ws.commons.schema.constants.Constants;
-import org.apache.yoko.tools.common.CorbaPrimitiveMap;
-import org.apache.yoko.tools.common.XmlSchemaPrimitiveMap;
-import org.apache.yoko.wsdl.CorbaConstants;
-import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public final class TypesUtils {
 
-    static CorbaPrimitiveMap corbaPrimitiveMap = new CorbaPrimitiveMap();
-    static XmlSchemaPrimitiveMap xmlSchemaPrimitiveMap = new XmlSchemaPrimitiveMap();
-
     private TypesUtils() {
         //complete
     }
-
-    public static XmlSchemaType findType(XmlSchemaCollection schemas, XmlSchema schema, AST node) {
-        XmlSchemaType result = null; 
-        QName corbaType = getPrimitiveType(node);
-        if (corbaType != null) {
-            QName schemaType = xmlSchemaPrimitiveMap.get(corbaType);
-            if (schemaType != null) {
-                result = schemas.getTypeByQName(schemaType);
-            }
-        }
-        if (result == null) {
-            //REVISIT, properly reference the node name, need to look at the siblings.
-            QName qname = new QName(schema.getTargetNamespace(), node.toString());
-            result = schema.getTypeByName(qname);
-        }
-        if (result == null) {
-            // template_type_spec
-            System.out.println("Invalid IDL! Error parsing: " + node.toStringTree());
-        }
-        return result;
-    }
-
-    public static CorbaTypeImpl findCorbaType(TypeMappingType typeMap, QName schemaTypeName) {
-        CorbaTypeImpl result = (CorbaTypeImpl) corbaPrimitiveMap.get(schemaTypeName);
-        if (result == null) {
-            Iterator corbaTypes = typeMap.getStructOrExceptionOrUnion().iterator();
-            while (corbaTypes.hasNext()) {
-                CorbaTypeImpl type = (CorbaTypeImpl) corbaTypes.next();
-                if (type.getQName().getLocalPart().equals(schemaTypeName.getLocalPart())) {
-                    result = type;
-                    break;
-                }
-            }
-        }
-        return result;
-    }
-
-    public static QName findCorbaTypeName(TypeMappingType typeMap, AST node) {
-        return getPrimitiveType(node);
-    }
     
     /** Returns node corresponding to the name of the CORBA primitive type node.
      * 
@@ -104,77 +50,50 @@
         return currentNode.getNextSibling();
     }
     
-    private static QName getPrimitiveType(AST node) {
-        QName result = null;
-        switch (node.getType()) {
-        case IDLTokenTypes.LITERAL_long:
-            if ((node.getNextSibling() != null)
-                && (node.getNextSibling().getType() == IDLTokenTypes.LITERAL_long)) {
-                // long long
-                result = CorbaConstants.NT_CORBA_LONGLONG;
-            } else if ((node.getFirstChild() != null)
-                && (node.getFirstChild().getType() == IDLTokenTypes.LITERAL_double)) {
-                // "double" node is a child of "long" node - instead of being a sibling
-                // long double
-                result = CorbaConstants.NT_CORBA_LONGDOUBLE;
-            } else {
-                // long
-                result = CorbaConstants.NT_CORBA_LONG;
-            }
-            break;
-        case IDLTokenTypes.LITERAL_unsigned:
-            AST node2 = node.getNextSibling();
-            if (node2 != null && node2.getType() == IDLTokenTypes.LITERAL_short) {
-                // unsigned short
-                result = CorbaConstants.NT_CORBA_USHORT;
-            } else if (node2 != null && node2.getType() == IDLTokenTypes.LITERAL_long) {
-                AST node3 = node2.getNextSibling();
-                if (node3 != null && node3.getType() == IDLTokenTypes.LITERAL_long) {
-                    // unsigned long long
-                    result = CorbaConstants.NT_CORBA_ULONGLONG;
-                } else {
-                    // unsigned long
-                    result = CorbaConstants.NT_CORBA_ULONG;
-                }
-            } else {
-                // TBD: we should never get here
+    public static boolean isValidIdentifier(String id) {
+        boolean result = true;
+        // From the CORBA IDL spec (section 3.2.3):
+        //   An identifier is an arbitrarily long sequence of ASCII alphabetic, digit,
+        //   and underscore ("_") characters. The first character must be an ASCII 
+        //   alphabetic character. All characters are significant.
+        //
+        // See section 3.2.3.1 for escaped identifiers (that start with a "_")
+        //
+        if (!Character.isLetter(id.charAt(0))) {
+            result = false;
+        }
+        if (id.charAt(0) == '_') {
+            result = false;
+        }
+        int index = 1;
+        while (result && index < id.length()) {
+            char cur = id.charAt(index);
+            if (!Character.isLetterOrDigit(cur)
+                || cur == '_') {
+                result = false;
             }
-            break;
-        case IDLTokenTypes.LITERAL_short:
-            result = CorbaConstants.NT_CORBA_SHORT;
-            break;
-        case IDLTokenTypes.LITERAL_float:
-            result = CorbaConstants.NT_CORBA_FLOAT;
-            break;            
-        case IDLTokenTypes.LITERAL_double:
-            result = CorbaConstants.NT_CORBA_DOUBLE;
-            break;            
-        case IDLTokenTypes.LITERAL_char:
-            result = CorbaConstants.NT_CORBA_CHAR;
-            break;
-        case IDLTokenTypes.LITERAL_wchar:
-            result = CorbaConstants.NT_CORBA_WCHAR;
-            break;
-        case IDLTokenTypes.LITERAL_string:
-            result = CorbaConstants.NT_CORBA_STRING;
-            break;
-        case IDLTokenTypes.LITERAL_wstring:
-            result = CorbaConstants.NT_CORBA_WSTRING;
-            break;
-        case IDLTokenTypes.LITERAL_boolean:
-            result = CorbaConstants.NT_CORBA_BOOLEAN;
-            break;
-        case IDLTokenTypes.LITERAL_octet:
-            result = CorbaConstants.NT_CORBA_OCTET;
-            break;
-        case IDLTokenTypes.LITERAL_any:
-            result = CorbaConstants.NT_CORBA_ANY;
-            break;
-        default:
-            // TBD 
-            break;
+            index++;
         }
         return result;
+    }
+    
+    public static Scope generateAnonymousScopedName(Scope scope, XmlSchema schema) {
+        Scope scopedName = null;
+        XmlSchemaType anonSchemaType = null;
+        Integer id = 0;
+        do {
+            id++;
+            StringBuffer name = new StringBuffer();
+            name.append("_");
+            name.append(id.toString());
+            name.append("_");
+            name.append(scope.tail());
+            scopedName = new Scope(scope.getParent(), name.toString());
+            QName scopedQName = new QName(schema.getTargetNamespace(), scopedName.toString());
+            anonSchemaType = schema.getTypeByName(scopedQName);
+        } while (anonSchemaType != null);
+        
+        return scopedName;
     }
 
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java Tue Nov 28 07:42:24 2006
@@ -19,18 +19,6 @@
 
 package org.apache.yoko.tools.processors.idl;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Types;
-import javax.wsdl.WSDLException;
-import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.factory.WSDLFactory;
-
-import javax.xml.namespace.QName;
-
-import antlr.ASTVisitor;
 import antlr.collections.AST;
 
 import org.apache.schemas.yoko.bindings.corba.ArgType;
@@ -38,228 +26,62 @@
 
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
-import org.apache.ws.commons.schema.XmlSchemaSerializer;
-import org.apache.ws.commons.schema.XmlSchemaType;
-import org.apache.ws.commons.schema.constants.Constants;
-import org.apache.ws.commons.schema.utils.NamespaceMap;
 
-import org.apache.yoko.wsdl.CorbaConstants;
-import org.apache.yoko.wsdl.CorbaTypeImpl;
-
-public class TypesVisitor implements ASTVisitor {
+public class TypesVisitor extends VisitorBase {
     
-    static final List<Integer> PRIMITIVE_TYPES = new ArrayList<Integer>();
     static final int PRIMITIVE = 0;
-
-    TypeMappingType typeMap;
-
-    Definition definition;
-    WSDLFactory wsdlFactory;
-
-    WSDLASTVisitor wsdlASTVisitor;
     
-    XmlSchema schema;
-    XmlSchemaCollection schemas;
     XmlSchemaObject currentType;
 
     ArgType currentParam;
 
-    List<String> parts = new ArrayList<String>();
-
-    public TypesVisitor(WSDLASTVisitor visitor)
-        throws WSDLException {
-        wsdlASTVisitor = visitor;
-        definition = visitor.getDefinition();
-        schemas = new XmlSchemaCollection();
-        schema = new XmlSchema(definition.getTargetNamespace(), schemas);
-        //add the anyType to the xml schema.
-        addAnyType();
-        createCorbaTypeMap();
-    }
-
-    // REVISIT: remove this method
-    // schema should not be a member of TypesVisitor
-    public XmlSchema getSchema() {
-        return schema;
-    }
-    
-    // REVISIT: remove this method
-    // schemas should not be a member of TypesVisitor
-    public XmlSchemaCollection getSchemas() {
-        return schemas;
-    }
-    
-    public TypeMappingType getCorbaTypeMapping() {
-        return typeMap;
-    }
-    
-    public void attachSchema() throws Exception {
-        Types types = definition.createTypes();
-        Schema wsdlSchema = (Schema) 
-            definition.getExtensionRegistry().createExtension(Types.class,
-                                                              new QName(Constants.URI_2001_SCHEMA_XSD,
-                                                                        "schema"));
-        NamespaceMap nsMap = new NamespaceMap();
-        nsMap.add("xs", Constants.URI_2001_SCHEMA_XSD);
-        schema.setNamespaceContext(nsMap);
-        org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
-        wsdlSchema.setElement(el);
-        types.addExtensibilityElement(wsdlSchema);
-        definition.setTypes(types);
-    }
-    
-    /*-
-     * Build the Wrapped Document Style wrapping elements
-     * i.e. <xs:element name="...">
-     *       <xs:complexType>
-     *        <xs:sequence>
-     *         ...
-     *        </xs:sequence>
-     *       </xs:complexType>
-     *      </xs:element>
-     */
-    public void addWrapper(QName el, XmlSchemaSequence wrappingSequence) {
-        XmlSchemaComplexType schemaComplexType = new XmlSchemaComplexType(schema);
-        schemaComplexType.setParticle(wrappingSequence);
-        
-        XmlSchemaElement wrappingSchemaElement = new XmlSchemaElement();
-        wrappingSchemaElement.setQName(el);
-        wrappingSchemaElement.setName(el.getLocalPart());
-        wrappingSchemaElement.setSchemaType(schemaComplexType);
-
-        schema.getElements().add(el, wrappingSchemaElement);
-        schema.getItems().add(wrappingSchemaElement);
-    }
-
-    public XmlSchemaElement addElement(XmlSchemaSequence schemaSequence, QName el, String name) {
-        XmlSchemaElement element = new XmlSchemaElement();
-        element.setQName(el);
-        element.setName(name);
+    private AST identifierNode;
 
-        schemaSequence.getItems().add(element);
-        
-        return element;
-    }
-
-    public void setCurrentPart(XmlSchemaElement element, String name, ArgType param) {
-        //get the element & check if a type has been set
-        if (element != null && element.getSchemaType() == null) {
-            currentType = element;
-            parts.add(name);
-            currentParam = param;
-        }
+    // identifierNode null if anonymous type
+    public TypesVisitor(Scope scope,
+                        XmlSchemaCollection xmlSchemas,
+                        XmlSchema xmlSchema,
+                        TypeMappingType corbaTypeMap,
+                        AST identifierNodeRef) {
+        super(scope, xmlSchemas, xmlSchema, corbaTypeMap);
+        identifierNode = identifierNodeRef;
     }
 
     public void visit(AST node) {
-        int type = getType(node);
-        TypesVisitorBase visitor = null;
-        switch (type) {
-        case PRIMITIVE: {
-            visitor = new PrimitiveTypesVisitor(schemas, schema, typeMap);
-            visitor.visit(node);
-            if (currentType instanceof XmlSchemaElement) {
-                ((XmlSchemaElement) currentType).setSchemaTypeName(visitor.getSchemaTypeName());
-                currentParam.setIdltype(visitor.getCorbaTypeName());
-            }
-            break;
-        }
-        case IDLTokenTypes.LITERAL_typedef: {
-            visitor = new TypedefVisitor(schemas, schema, typeMap);
-            visitor.visit(node);
-            break;
-        }
-        case IDLTokenTypes.LITERAL_struct: {
-            visitor = new StructVisitor(schemas, schema, typeMap);
-            visitor.visit(node);
-            break;
-        }
-        case IDLTokenTypes.LITERAL_exception: {
-            visitor = new ExceptionVisitor(schemas, schema, typeMap);
-            visitor.visit(node);
-            break;
-        }
-        case IDLTokenTypes.LITERAL_const:
-            ConstVisitor constVisitor = new ConstVisitor(schemas, schema, typeMap);
-            constVisitor.visit(node);
-            break;
-        case IDLTokenTypes.LITERAL_enum:
-            EnumVisitor enumVisitor = new EnumVisitor(schemas, schema, typeMap);
-            enumVisitor.visit(node);
-            break;
-        case IDLTokenTypes.LITERAL_union:
-            UnionVisitor unionVisitor = new UnionVisitor(schemas, schema, typeMap);
-            unionVisitor.visit(node);
-            break;
-        case IDLTokenTypes.IDENT: {
-            XmlSchemaType stype = TypesUtils.findType(schemas, schema, node);
-            if (currentType instanceof XmlSchemaElement) {
-                QName qname = stype.getQName();
-                ((XmlSchemaElement) currentType).setSchemaTypeName(qname);
-                CorbaTypeImpl corbaType = TypesUtils.findCorbaType(typeMap, qname);
-                currentParam.setIdltype(corbaType.getQName());
-            }
-            break;
-        }
-        default: {
-            System.err.println("Type not yet supported : " + node);
-        }
-        }
+        // <type_spec> ::= <simple_type_spec>
+        //               | <constr_type_spec>
 
-    }
-
-    private int getType(AST node) {
-        if (isPrimitive(node.getType())) {
-            return PRIMITIVE;
-        } else {
-            return node.getType();
-        }
-    }
-
-    private boolean isPrimitive(int nodeType) {
-        return PRIMITIVE_TYPES.contains(nodeType);
-    }
-
-    private void createCorbaTypeMap() throws WSDLException { 
-        typeMap = (TypeMappingType)
-            definition.getExtensionRegistry().createExtension(Definition.class,
-                                                              CorbaConstants.NE_CORBA_TYPEMAPPING);
-        typeMap.setTargetNamespace(definition.getTargetNamespace()
-                                  + "/"
-                                  + CorbaConstants.NS_CORBA_TYPEMAP);
-        definition.addExtensibilityElement(typeMap);
-    }
-
-    private void addAnyType() {
-        XmlSchema[] schemaList = schemas.getXmlSchemas();
-        if (schemaList != null) {
-            for (int i = 0; i < schemaList.length; i++) {
-                if (schemaList[i].getTargetNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                    XmlSchemaType anyType = new XmlSchemaType(schemaList[0]);
-                    anyType.setName(Constants.XSD_ANYTYPE.getLocalPart());
-                    schemaList[i].addType(anyType);
-                    break;
-                }
-            }
+        Visitor visitor = null;
+        
+        
+        if (ConstrTypeSpecVisitor.accept(node)) {
+            // type_spec - constr_type_spec
+            visitor = new ConstrTypeSpecVisitor(getScope(), schemas, schema, typeMap, identifierNode);
+        } else if (SimpleTypeSpecVisitor.accept(node)) {
+            // type_spec - simple_type_spec
+            visitor = new SimpleTypeSpecVisitor(getScope(), schemas, schema, typeMap, identifierNode);
+        } else if (visitor == null) {
+            // REVISIT: !!!!!
+            // This is ugly. It should be done in the SimpleTypeSpecVisitor.accept(node) method.
+            // More precisely, that accept method should contained an ORed 
+            // ScopedNameVisitor.accept(schemas, schema, node)
+            // It is not done currently because that would require changing accept method signature 
+            // to accept(schemas, schema, node).
+            // Perhaps passing a pointer to DefinitionVisitor or some other class (to be designed)
+            // would be a better solution.
+            //
+            // To work around that redesign and get things working now, I am assuming that if visitor
+            // is null at this point, then it has to be a scoped_name.
+            // REVISIT!!!
+            visitor = new ScopedNameVisitor(getScope(), schemas, schema, typeMap);
         }
-    }
+        
+        visitor.visit(node);
 
-    static {
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_float));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_double));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_long));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_short));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_unsigned));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_char));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_wchar));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_boolean));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_any));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_octet));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_string));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_wstring));
+        setSchemaType(visitor.getSchemaType());
+        setCorbaType(visitor.getCorbaType());
+        
     }
 
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java Tue Nov 28 07:42:24 2006
@@ -48,6 +48,8 @@
         typeMap = typeMapRef;
     }
 
+    public abstract void visit(AST node);
+
     public XmlSchema getSchema() {
         return schema;
     }
@@ -55,9 +57,6 @@
     public TypeMappingType getCorbaTypeMap() {
         return typeMap;
     }
-
-
-    public abstract void visit(AST node);
 
     public XmlSchemaType getSchemaType() {
         return schemaType;

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java Tue Nov 28 07:42:24 2006
@@ -37,32 +37,64 @@
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class UnionVisitor extends TypesVisitorBase {
+public class UnionVisitor extends VisitorBase {
 
     private final String discriminator = "discriminator";
     
-    public UnionVisitor(XmlSchemaCollection xmlSchemas,
-                       XmlSchema xmlSchema,
-                       TypeMappingType typeMappingType) {
-        super(xmlSchemas, xmlSchema, typeMappingType);
+    public UnionVisitor(Scope scope,
+                        XmlSchemaCollection xmlSchemas,
+                        XmlSchema xmlSchema,
+                        TypeMappingType typeMappingType) {
+        super(scope, xmlSchemas, xmlSchema, typeMappingType);
+    }
+    
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_union) {
+            return true;
+        }
+        return false;
     }
     
     public void visit(AST unionNode) {
+        // <union_type> ::= "union" <identifier> "switch" "(" <switch_type_spec> ")"
+        //                  "{" <switch_body> "}"
+        // <switch_type_spec> ::= <integer_type>
+        //                      | <char_type>
+        //                      | <boolean_type>
+        //                      | <enum_type>
+        //                      | <scoped_type>
+        // <switch_body> ::= <case>+
+        // <case> ::= <case_label>+ <element_spec> ";"
+        // <case_label> ::= "case" <const_expr> ":"
+        //                | "default" ":"
+        // <element_spec> ::= <type_spec> <declarator>
+        
+        
         AST identifierNode = unionNode.getFirstChild();
+        Scope unionScope = new Scope(getScope(), identifierNode);
         AST discriminatorNode = identifierNode.getNextSibling();
         AST caseNode = discriminatorNode.getNextSibling();
 
         // xmlschema:union
         XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema);
         XmlSchemaSequence sequence = new XmlSchemaSequence();
-        unionSchemaComplexType.setName(identifierNode.toString());
+        unionSchemaComplexType.setName(unionScope.toString());
         unionSchemaComplexType.setParticle(sequence);
         
+        // REVISIT
+        // TEMPORARILY 
+        // using TypesVisitor to visit <const_type>
+        // it should be visited by a SwitchTypeSpecVisitor
+        TypesVisitor visitor = new TypesVisitor(getScope(), schemas, schema, typeMap, null);
+        visitor.visit(discriminatorNode);
+        XmlSchemaType stype = visitor.getSchemaType();
+        CorbaTypeImpl ctype = visitor.getCorbaType();
+        
         XmlSchemaElement discriminatorElement = new XmlSchemaElement();
-        XmlSchemaType type = TypesUtils.findType(schemas, schema, discriminatorNode);
         discriminatorElement.setName(discriminator);
-        discriminatorElement.setSchemaTypeName(type.getQName());
+        discriminatorElement.setSchemaTypeName(stype.getQName());
         discriminatorElement.setMinOccurs(1);
         discriminatorElement.setMaxOccurs(1);
         sequence.getItems().add(discriminatorElement);
@@ -75,25 +107,34 @@
         
         // corba:union
         Union corbaUnion = new Union();
-        corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), identifierNode.toString()));
+        corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
         corbaUnion.setRepositoryID(CorbaConstants.REPO_STRING
-                                   + identifierNode.toString()
+                                   + unionScope.toIDLRepositoryID()
                                    + CorbaConstants.IDL_VERSION);
         corbaUnion.setType(unionSchemaComplexType.getQName());
-        corbaUnion.setDiscriminator(TypesUtils.findCorbaType(typeMap, type.getQName()).getQName());
+        corbaUnion.setDiscriminator(ctype.getQName());
         
-        processCaseNodes(caseNode, choice, corbaUnion);
+        processCaseNodes(caseNode, unionScope, choice, corbaUnion);
             
         
-        // add xmlschema:union
-        schema.getItems().add(unionSchemaComplexType);
-        schema.addType(unionSchemaComplexType);
-
-        // add corba:union
-        typeMap.getStructOrExceptionOrUnion().add(corbaUnion);
+        XmlSchemaType schemaType = unionSchemaComplexType;
+        CorbaTypeImpl corbaType = corbaUnion;
+        // declaration phase
+        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(getScope(),
+                                                                    schemas,
+                                                                    schema,
+                                                                    typeMap,
+                                                                    schemaType,
+                                                                    corbaType);
+        declaratorVisitor.visit(identifierNode);
+
+        // REVISIT: are these assignments needed?
+        setSchemaType(unionSchemaComplexType);
+        setCorbaType(corbaUnion);
     }
     
     private void processCaseNodes(AST caseNode,
+                                  Scope scope,
                                   XmlSchemaChoice choice,
                                   Union corbaUnion) {
         while (caseNode != null) {
@@ -126,17 +167,42 @@
                 nameNode = typeNode.getNextSibling();
             }
             
+
+            TypesVisitor visitor = new TypesVisitor(scope,
+                                                    schemas,
+                                                    schema,
+                                                    typeMap,
+                                                    null);
+            visitor.visit(typeNode);
+            XmlSchemaType stype = visitor.getSchemaType();
+            CorbaTypeImpl ctype = visitor.getCorbaType();
+            
+            
+            // needed for anonymous arrays in unions
+            if (ArrayVisitor.accept(nameNode)) {
+                Scope anonScope = new Scope(scope, TypesUtils.getPrimitiveCorbaTypeNameNode(nameNode));
+                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
+                                                             schemas,
+                                                             schema,
+                                                             typeMap,
+                                                             stype,
+                                                             ctype,
+                                                             null);
+                arrayVisitor.visit(nameNode);
+                stype = arrayVisitor.getSchemaType();
+                ctype = arrayVisitor.getCorbaType();
+            }
+            
+            
             // xmlschema:element
             element.setName(nameNode.toString());
-            XmlSchemaType type = TypesUtils.findType(schemas, schema, typeNode);
-            element.setSchemaTypeName(type.getQName());
+            element.setSchemaTypeName(stype.getQName());
             choice.getItems().add(element);
             
             
             // corba:unionbranch
             unionBranch.setName(nameNode.toString());
-            QName idlType = TypesUtils.findCorbaType(typeMap, type.getQName()).getQName();
-            unionBranch.setIdltype(idlType);
+            unionBranch.setIdltype(ctype.getQName());
             corbaUnion.getUnionbranch().add(unionBranch);
             
             

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Visitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/VisitorBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java Tue Nov 28 07:42:24 2006
@@ -29,12 +29,15 @@
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
+import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.factory.WSDLFactory;
 
 import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
 
 import antlr.ASTVisitor;
 import antlr.collections.AST;
@@ -44,6 +47,13 @@
 import org.apache.schemas.yoko.bindings.corba.OperationType;
 import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
 
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaSerializer;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+
 import org.apache.yoko.tools.common.WSDLUtils;
 import org.apache.yoko.wsdl.CorbaConstants;
 
@@ -54,43 +64,41 @@
     
     Definition definition;
     WSDLFactory wsdlFactory;
-    PortTypeVisitor portTypeVisitor;
-    TypesVisitor typesVisitor;
+
+    XmlSchema schema;
+    XmlSchemaCollection schemas;
+    
+    TypeMappingType typeMap;
 
     public WSDLASTVisitor(String tns)
         throws WSDLException, JAXBException {
-        wsdlFactory = WSDLFactory.newInstance();
-        definition = wsdlFactory.newDefinition();
-        definition.setTargetNamespace(tns);
-        definition.addNamespace(WSDLConstants.WSDL_PREFIX, WSDLConstants.NS_WSDL);
-        definition.addNamespace(WSDLConstants.XSD_PREFIX, WSDLConstants.XSD_NAMESPACE);
-        definition.addNamespace(WSDLConstants.SOAP_PREFIX, WSDLConstants.SOAP11_NAMESPACE);
-        definition.addNamespace(WSDLConstants.TNS_PREFIX, tns);
-        definition.addNamespace(CorbaConstants.NP_WSDL_CORBA, CorbaConstants.NU_WSDL_CORBA);
-        addCorbaExtensions(definition.getExtensionRegistry());
-        initVisitors();
+        
+        createWsdlDefinition(tns);
+        
+        schemas = new XmlSchemaCollection();
+        schema = new XmlSchema(definition.getTargetNamespace(), schemas);
+
+        addAnyType();
+        
+        createCorbaTypeMap();
     }
 
     public void visit(AST node) {
+        // <specification> ::= <definition>+
+
         while (node != null) {
-            switch (node.getType()) {
-            case IDLTokenTypes.LITERAL_interface: {
-                portTypeVisitor.visit(node);
-                break;
-            }
-            case IDLTokenTypes.LITERAL_module: {
-                node = node.getFirstChild();
-                portTypeVisitor.addModuleName(node.toString());
-                break;
-            }
-            default: {
-                typesVisitor.visit(node);
-            }
-            }            
+            DefinitionVisitor definitionVisitor = new DefinitionVisitor(new Scope(),
+                                                                        definition,
+                                                                        schemas,
+                                                                        schema,
+                                                                        typeMap);
+            definitionVisitor.visit(node);
+
             node = node.getNextSibling();
         }
+        
         try {
-            typesVisitor.attachSchema();
+            attachSchema();
         } catch (Exception ex) {
             throw new RuntimeException(ex);
         }
@@ -104,10 +112,6 @@
         return wsdlFactory;
     }
 
-    public TypesVisitor getTypesVisitor() {
-        return typesVisitor;
-    }
-
     public Binding[] getCorbaBindings() {
         List<Binding> result = new ArrayList<Binding>();
         Map bindings = definition.getBindings();
@@ -126,16 +130,33 @@
         return (Binding[]) result.toArray(new Binding[result.size()]);
     }
 
-    private void initVisitors() throws WSDLException {
-        typesVisitor = new TypesVisitor(this);
-        portTypeVisitor = new PortTypeVisitor(this);
-    }
-
     public boolean writeDefinition(Writer writer) throws Exception {
         WSDLUtils.writeWSDL(definition, writer);
         return true;
     }
 
+    private void createWsdlDefinition(String tns) throws WSDLException, JAXBException {
+        wsdlFactory = WSDLFactory.newInstance();
+        definition = wsdlFactory.newDefinition();
+        definition.setTargetNamespace(tns);
+        definition.addNamespace(WSDLConstants.WSDL_PREFIX, WSDLConstants.NS_WSDL);
+        definition.addNamespace(WSDLConstants.XSD_PREFIX, WSDLConstants.XSD_NAMESPACE);
+        definition.addNamespace(WSDLConstants.SOAP_PREFIX, WSDLConstants.SOAP11_NAMESPACE);
+        definition.addNamespace(WSDLConstants.TNS_PREFIX, tns);
+        definition.addNamespace(CorbaConstants.NP_WSDL_CORBA, CorbaConstants.NU_WSDL_CORBA);
+        addCorbaExtensions(definition.getExtensionRegistry());
+    }
+    
+    private void createCorbaTypeMap() throws WSDLException { 
+        typeMap = (TypeMappingType)
+            definition.getExtensionRegistry().createExtension(Definition.class,
+                                                              CorbaConstants.NE_CORBA_TYPEMAPPING);
+        typeMap.setTargetNamespace(definition.getTargetNamespace()
+                                   + "/"
+                                   + CorbaConstants.NS_CORBA_TYPEMAP);
+        definition.addExtensibilityElement(typeMap);
+    }
+
     private void addCorbaExtensions(ExtensionRegistry extReg) throws JAXBException {
         try {                      
             JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class);
@@ -154,5 +175,34 @@
             throw new JAXBException(ex.getMessage());
         }
     }    
+
+    private void attachSchema() throws Exception {
+        Types types = definition.createTypes();
+        Schema wsdlSchema = (Schema) 
+            definition.getExtensionRegistry().createExtension(Types.class,
+                                                              new QName(Constants.URI_2001_SCHEMA_XSD,
+                                                                        "schema"));
+        NamespaceMap nsMap = new NamespaceMap();
+        nsMap.add("xs", Constants.URI_2001_SCHEMA_XSD);
+        schema.setNamespaceContext(nsMap);
+        org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
+        wsdlSchema.setElement(el);
+        types.addExtensibilityElement(wsdlSchema);
+        definition.setTypes(types);
+    }
+
+    private void addAnyType() {
+        XmlSchema[] schemaList = schemas.getXmlSchemas();
+        if (schemaList != null) {
+            for (int i = 0; i < schemaList.length; i++) {
+                if (schemaList[i].getTargetNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
+                    XmlSchemaType anyType = new XmlSchemaType(schemaList[0]);
+                    anyType.setName(Constants.XSD_ANYTYPE.getLocalPart());
+                    schemaList[i].addType(anyType);
+                    break;
+                }
+            }
+        }
+    }
 
 }

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java Tue Nov 28 07:42:24 2006
@@ -174,4 +174,28 @@
         testWSDLGeneration("/idl/Attributes.idl", "/idl/expected_Attributes.wsdl");
     }
 
+    public void testSequenceGeneration() throws Exception {
+        testWSDLGeneration("/idl/Sequence.idl", "/idl/expected_Sequence.wsdl");
+    }
+
+    public void testArrayGeneration() throws Exception {
+        testWSDLGeneration("/idl/Array.idl", "/idl/expected_Array.wsdl");
+    }
+
+    public void testAnonarrayGeneration() throws Exception {
+        testWSDLGeneration("/idl/Anonarray.idl", "/idl/expected_Anonarray.wsdl");
+    }
+
+    public void testAnonsequenceGeneration() throws Exception {
+        testWSDLGeneration("/idl/Anonsequence.idl", "/idl/expected_Anonsequence.wsdl");
+    }
+
+    public void testAnonboundedsequenceGeneration() throws Exception {
+        testWSDLGeneration("/idl/Anonboundedsequence.idl", "/idl/expected_Anonboundedsequence.wsdl");
+    }
+
+    public void testAnonstringGeneration() throws Exception {
+        testWSDLGeneration("/idl/Anonstring.idl", "/idl/expected_Anonstring.wsdl");
+    }
+
 }

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl Tue Nov 28 07:42:24 2006
@@ -33,13 +33,13 @@
 	void if2_op3(inout e_type1 inout_e_type1);
 };
 
-/*
-module M
+module m1
 {
         enum e_type3 {e3_1, e3_2, e3_3};
-        interface if2 {
-                        enum e_type4 {e4_1, e4_2, e4_3};
+        interface if3 {
+                enum e_type4 {e4_1, e4_2, e4_3};
+		void if3_op1(in e_type3 in_e_type3);
+                void if3_op2(in e_type4 in_e_type4);
         };
 
 };
-*/

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/Typedef.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/Typedef.idl?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/Typedef.idl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/Typedef.idl Tue Nov 28 07:42:24 2006
@@ -95,8 +95,6 @@
     void opIn(	
                 in myFloat            inMyFloat,
                 in myDouble           inMyDouble,
-                in myFloat            inMyFloat,
-                in myDouble           inMyDouble,
                 in myLongDouble       inMyLongDouble,
                 in myShort            inMyShort,
                 in myLong             inMyLong,
@@ -127,8 +125,6 @@
     void opOut(	
                 out myFloat            outMyFloat,
                 out myDouble           outMyDouble,
-                out myFloat            outMyFloat,
-                out myDouble           outMyDouble,
                 out myLongDouble       outMyLongDouble,
                 out myShort            outMyShort,
                 out myLong             outMyLong,
@@ -157,8 +153,6 @@
     );
 
     void opInOut(
-                 inout myFloat            inoutMyFloat,
-                 inout myDouble           inoutMyDouble,
                  inout myFloat            inoutMyFloat,
                  inout myDouble           inoutMyDouble,
                  inout myLongDouble       inoutMyLongDouble,

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonarray.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonarray.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonboundedsequence.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonboundedsequence.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonsequence.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonsequence.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonstring.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonstring.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Array.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Array.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Attributes.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_Attributes.wsdl?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_Attributes.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_Attributes.wsdl Tue Nov 28 07:42:24 2006
@@ -23,8 +23,8 @@
       <corba:member name="id" idltype="corba:long" />
       <corba:member name="name" idltype="corba:string" />
     </corba:struct>
-      <corba:anonstring xmlns:ns4="http://schemas.apache.org/yoko/idl/Attributes" xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" bound="20" name="_1_myString" type="ns4:myString" />
-      <corba:alias xmlns:ns4="http://schemas.apache.org/yoko/idl/Attributes" xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" basetype="_1_myString" repositoryID="IDL:myString:1.0" name="myString" type="ns4:myString" />
+      <corba:anonstring xmlns:ns4="http://schemas.apache.org/yoko/idl/Attributes" xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" bound="20" name="If._1_myString" type="ns4:If.myString" />
+      <corba:alias xmlns:ns4="http://schemas.apache.org/yoko/idl/Attributes" xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" basetype="If._1_myString" repositoryID="IDL:If/myString:1.0" name="If.myString" type="ns4:If.myString" />
     </corba:typeMapping>
   <wsdl:types>
     <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/Attributes" xmlns="http://schemas.apache.org/yoko/idl/Attributes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
@@ -120,7 +120,7 @@
           </xs:sequence>
         </xs:complexType>
       </xs:element>
-      <xs:simpleType name="myString">
+      <xs:simpleType name="If.myString">
         <xs:restriction base="xs:string">
           <xs:maxLength value="20">
           </xs:maxLength>
@@ -135,7 +135,7 @@
       <xs:element name="_get_readonlyMyStringResult">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="return" type="myString">
+            <xs:element name="return" type="If.myString">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -149,7 +149,7 @@
       <xs:element name="_get_readwriteMyStringResult">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="return" type="myString">
+            <xs:element name="return" type="If.myString">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -157,7 +157,7 @@
       <xs:element name="_set_readwriteMyString">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="_arg" type="myString">
+            <xs:element name="_arg" type="If.myString">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -320,7 +320,7 @@
     </wsdl:operation>
     <wsdl:operation name="_get_readonlyMyString">
       <corba:operation name="_get_readonlyMyString">
-        <corba:return xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" name="return" idltype="myString" />
+        <corba:return xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" name="return" idltype="If.myString" />
       </corba:operation>
       <wsdl:input name="_get_readonlyMyString">
       </wsdl:input>
@@ -329,7 +329,7 @@
     </wsdl:operation>
     <wsdl:operation name="_get_readwriteMyString">
       <corba:operation name="_get_readwriteMyString">
-        <corba:return xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" name="return" idltype="myString" />
+        <corba:return xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" name="return" idltype="If.myString" />
       </corba:operation>
       <wsdl:input name="_get_readwriteMyString">
       </wsdl:input>
@@ -338,7 +338,7 @@
     </wsdl:operation>
     <wsdl:operation name="_set_readwriteMyString">
       <corba:operation name="_set_readwriteMyString">
-        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" mode="in" name="_arg" idltype="myString" />
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Attributes/typemap" mode="in" name="_arg" idltype="If.myString" />
       </corba:operation>
       <wsdl:input name="_set_readwriteMyString">
       </wsdl:input>

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Const.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_Const.wsdl?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_Const.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_Const.wsdl Tue Nov 28 07:42:24 2006
@@ -34,21 +34,21 @@
     <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global string" idltype="corba:string" name="glob_string" type="xs:string" />
     <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global wide string" idltype="corba:wstring" name="glob_wstring" type="xs:string" />
     <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="0x1" idltype="corba:octet" name="glob_octet" type="xs:unsignedByte" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-12" idltype="corba:short" name="inter_short" type="xs:short" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="2334" idltype="corba:long" name="inter_long" type="xs:int" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-123456789" idltype="corba:longlong" name="inter_longlong" type="xs:long" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="15" idltype="corba:ushort" name="inter_unsignedshort" type="xs:unsignedShort" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="4556" idltype="corba:ulong" name="inter_unsignedlong" type="xs:unsignedInt" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="123456789" idltype="corba:ulonglong" name="inter_unsignedlonglong" type="xs:unsignedLong" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="r" idltype="corba:char" name="inter_char" type="xs:byte" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="x" idltype="corba:wchar" name="inter_wchar" type="xs:string" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="FALSE" idltype="corba:boolean" name="inter_boolean" type="xs:boolean" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-67.9" idltype="corba:float" name="inter_float" type="xs:float" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-1.9e5" idltype="corba:double" name="inter_double" type="xs:double" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-3.2e8" idltype="corba:longdouble" name="inter_longdouble" type="xs:double" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global string" idltype="corba:string" name="inter_string" type="xs:string" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global wide string" idltype="corba:wstring" name="inter_wstring" type="xs:string" />
-    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="0x1" idltype="corba:octet" name="inter_octet" type="xs:unsignedByte" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-12" idltype="corba:short" name="constInterface.inter_short" type="xs:short" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="2334" idltype="corba:long" name="constInterface.inter_long" type="xs:int" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-123456789" idltype="corba:longlong" name="constInterface.inter_longlong" type="xs:long" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="15" idltype="corba:ushort" name="constInterface.inter_unsignedshort" type="xs:unsignedShort" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="4556" idltype="corba:ulong" name="constInterface.inter_unsignedlong" type="xs:unsignedInt" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="123456789" idltype="corba:ulonglong" name="constInterface.inter_unsignedlonglong" type="xs:unsignedLong" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="r" idltype="corba:char" name="constInterface.inter_char" type="xs:byte" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="x" idltype="corba:wchar" name="constInterface.inter_wchar" type="xs:string" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="FALSE" idltype="corba:boolean" name="constInterface.inter_boolean" type="xs:boolean" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-67.9" idltype="corba:float" name="constInterface.inter_float" type="xs:float" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-1.9e5" idltype="corba:double" name="constInterface.inter_double" type="xs:double" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="-3.2e8" idltype="corba:longdouble" name="constInterface.inter_longdouble" type="xs:double" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global string" idltype="corba:string" name="constInterface.inter_string" type="xs:string" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="this is a global wide string" idltype="corba:wstring" name="constInterface.inter_wstring" type="xs:string" />
+    <corba:const xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.apache.org/yoko/idl/Const/typemap" value="0x1" idltype="corba:octet" name="constInterface.inter_octet" type="xs:unsignedByte" />
   </corba:typeMapping>
   <wsdl:types>
     <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/Const" xmlns="http://schemas.apache.org/yoko/idl/Const" xmlns:xs="http://www.w3.org/2001/XMLSchema">

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl Tue Nov 28 07:42:24 2006
@@ -24,12 +24,22 @@
       <corba:enumerator value="e1_2" />
       <corba:enumerator value="e1_3" />
     </corba:enum>
-      <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:e_type2:1.0" name="e_type2" type="ns4:e_type2">
+      <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:if1/e_type2:1.0" name="if1.e_type2" type="ns4:if1.e_type2">
         <corba:enumerator value="e2_1" />
         <corba:enumerator value="e2_2" />
         <corba:enumerator value="e2_3" />
       </corba:enum>
-      </corba:typeMapping>
+        <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:m1/e_type3:1.0" name="m1.e_type3" type="ns4:m1.e_type3">
+          <corba:enumerator value="e3_1" />
+          <corba:enumerator value="e3_2" />
+          <corba:enumerator value="e3_3" />
+        </corba:enum>
+          <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:m1/if3/e_type4:1.0" name="m1.if3.e_type4" type="ns4:m1.if3.e_type4">
+            <corba:enumerator value="e4_1" />
+            <corba:enumerator value="e4_2" />
+            <corba:enumerator value="e4_3" />
+          </corba:enum>
+          </corba:typeMapping>
   <wsdl:types>
     <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:simpleType name="e_type1">
@@ -42,7 +52,7 @@
           </xs:enumeration>
         </xs:restriction>
       </xs:simpleType>
-      <xs:simpleType name="e_type2">
+      <xs:simpleType name="if1.e_type2">
         <xs:restriction base="xs:string">
           <xs:enumeration value="e2_1">
           </xs:enumeration>
@@ -55,7 +65,7 @@
       <xs:element name="if1_op1">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="in_e_type2" type="e_type2">
+            <xs:element name="in_e_type2" type="if1.e_type2">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -75,7 +85,7 @@
       <xs:element name="if1_op2Response">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="out_e_type2" type="e_type2">
+            <xs:element name="out_e_type2" type="if1.e_type2">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -83,7 +93,7 @@
       <xs:element name="if1_op3">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="inout_e_type2" type="e_type2">
+            <xs:element name="inout_e_type2" type="if1.e_type2">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -91,7 +101,7 @@
       <xs:element name="if1_op3Response">
         <xs:complexType>
           <xs:sequence>
-            <xs:element name="inout_e_type2" type="e_type2">
+            <xs:element name="inout_e_type2" type="if1.e_type2">
             </xs:element>
           </xs:sequence>
         </xs:complexType>
@@ -140,34 +150,73 @@
           </xs:sequence>
         </xs:complexType>
       </xs:element>
+      <xs:simpleType name="m1.e_type3">
+        <xs:restriction base="xs:string">
+          <xs:enumeration value="e3_1">
+          </xs:enumeration>
+          <xs:enumeration value="e3_2">
+          </xs:enumeration>
+          <xs:enumeration value="e3_3">
+          </xs:enumeration>
+        </xs:restriction>
+      </xs:simpleType>
+      <xs:simpleType name="m1.if3.e_type4">
+        <xs:restriction base="xs:string">
+          <xs:enumeration value="e4_1">
+          </xs:enumeration>
+          <xs:enumeration value="e4_2">
+          </xs:enumeration>
+          <xs:enumeration value="e4_3">
+          </xs:enumeration>
+        </xs:restriction>
+      </xs:simpleType>
+      <xs:element name="if3_op1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="in_e_type3" type="m1.e_type3">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="if3_op1Response">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="if3_op2">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="in_e_type4" type="m1.if3.e_type4">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="if3_op2Response">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
     </xs:schema>
   </wsdl:types>
-  <wsdl:message name="if1_op1Response">
-    <wsdl:part name="outparameter" element="tns:if1_op1Response"/>
-  </wsdl:message>
   <wsdl:message name="if2_op2">
     <wsdl:part name="inparameter" element="tns:if2_op2"/>
   </wsdl:message>
-  <wsdl:message name="if1_op3Response">
-    <wsdl:part name="outparameter" element="tns:if1_op3Response"/>
-  </wsdl:message>
   <wsdl:message name="if1_op1">
     <wsdl:part name="inparameter" element="tns:if1_op1"/>
   </wsdl:message>
-  <wsdl:message name="if2_op1Response">
-    <wsdl:part name="outparameter" element="tns:if2_op1Response"/>
-  </wsdl:message>
   <wsdl:message name="if2_op1">
     <wsdl:part name="inparameter" element="tns:if2_op1"/>
   </wsdl:message>
-  <wsdl:message name="if2_op3">
-    <wsdl:part name="inparameter" element="tns:if2_op3"/>
+  <wsdl:message name="if2_op1Response">
+    <wsdl:part name="outparameter" element="tns:if2_op1Response"/>
   </wsdl:message>
   <wsdl:message name="if1_op3">
     <wsdl:part name="inparameter" element="tns:if1_op3"/>
   </wsdl:message>
-  <wsdl:message name="if2_op3Response">
-    <wsdl:part name="outparameter" element="tns:if2_op3Response"/>
+  <wsdl:message name="if2_op3">
+    <wsdl:part name="inparameter" element="tns:if2_op3"/>
   </wsdl:message>
   <wsdl:message name="if1_op2">
     <wsdl:part name="inparameter" element="tns:if1_op2"/>
@@ -178,6 +227,37 @@
   <wsdl:message name="if1_op2Response">
     <wsdl:part name="outparameter" element="tns:if1_op2Response"/>
   </wsdl:message>
+  <wsdl:message name="if1_op1Response">
+    <wsdl:part name="outparameter" element="tns:if1_op1Response"/>
+  </wsdl:message>
+  <wsdl:message name="if3_op2Response">
+    <wsdl:part name="outparameter" element="tns:if3_op2Response"/>
+  </wsdl:message>
+  <wsdl:message name="if3_op1Response">
+    <wsdl:part name="outparameter" element="tns:if3_op1Response"/>
+  </wsdl:message>
+  <wsdl:message name="if1_op3Response">
+    <wsdl:part name="outparameter" element="tns:if1_op3Response"/>
+  </wsdl:message>
+  <wsdl:message name="if3_op1">
+    <wsdl:part name="inparameter" element="tns:if3_op1"/>
+  </wsdl:message>
+  <wsdl:message name="if2_op3Response">
+    <wsdl:part name="outparameter" element="tns:if2_op3Response"/>
+  </wsdl:message>
+  <wsdl:message name="if3_op2">
+    <wsdl:part name="inparameter" element="tns:if3_op2"/>
+  </wsdl:message>
+  <wsdl:portType name="m1.if3">
+    <wsdl:operation name="if3_op1">
+      <wsdl:input name="if3_op1Request" message="tns:if3_op1"/>
+      <wsdl:output name="if3_op1Response" message="tns:if3_op1Response"/>
+    </wsdl:operation>
+    <wsdl:operation name="if3_op2">
+      <wsdl:input name="if3_op2Request" message="tns:if3_op2"/>
+      <wsdl:output name="if3_op2Response" message="tns:if3_op2Response"/>
+    </wsdl:operation>
+  </wsdl:portType>
   <wsdl:portType name="if2">
     <wsdl:operation name="if2_op1">
       <wsdl:input name="if2_op1Request" message="tns:if2_op1"/>
@@ -206,11 +286,32 @@
       <wsdl:output name="if1_op3Response" message="tns:if1_op3Response"/>
     </wsdl:operation>
   </wsdl:portType>
+  <wsdl:binding name="m1.if3CORBABinding" type="tns:m1.if3">
+    <corba:binding repositoryID="IDL:m1/if3:1.0" />
+    <wsdl:operation name="if3_op1">
+      <corba:operation name="if3_op1">
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type3" idltype="m1.e_type3" />
+      </corba:operation>
+      <wsdl:input name="if3_op1Request">
+      </wsdl:input>
+      <wsdl:output name="if3_op1Response">
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="if3_op2">
+      <corba:operation name="if3_op2">
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type4" idltype="m1.if3.e_type4" />
+      </corba:operation>
+      <wsdl:input name="if3_op2Request">
+      </wsdl:input>
+      <wsdl:output name="if3_op2Response">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
   <wsdl:binding name="if1CORBABinding" type="tns:if1">
     <corba:binding repositoryID="IDL:if1:1.0" />
     <wsdl:operation name="if1_op1">
       <corba:operation name="if1_op1">
-        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type2" idltype="e_type2" />
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type2" idltype="if1.e_type2" />
       </corba:operation>
       <wsdl:input name="if1_op1Request">
       </wsdl:input>
@@ -219,7 +320,7 @@
     </wsdl:operation>
     <wsdl:operation name="if1_op2">
       <corba:operation name="if1_op2">
-        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="out" name="out_e_type2" idltype="e_type2" />
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="out" name="out_e_type2" idltype="if1.e_type2" />
       </corba:operation>
       <wsdl:input name="if1_op2Request">
       </wsdl:input>
@@ -228,7 +329,7 @@
     </wsdl:operation>
     <wsdl:operation name="if1_op3">
       <corba:operation name="if1_op3">
-        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="inout" name="inout_e_type2" idltype="e_type2" />
+        <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="inout" name="inout_e_type2" idltype="if1.e_type2" />
       </corba:operation>
       <wsdl:input name="if1_op3Request">
       </wsdl:input>
@@ -268,6 +369,11 @@
   </wsdl:binding>
   <wsdl:service name="if2CORBAService">
     <wsdl:port name="if2CORBAPort" binding="tns:if2CORBABinding">
+      <corba:address location="IOR:" />
+    </wsdl:port>
+  </wsdl:service>
+  <wsdl:service name="m1.if3CORBAService">
+    <wsdl:port name="m1.if3CORBAPort" binding="tns:m1.if3CORBABinding">
       <corba:address location="IOR:" />
     </wsdl:port>
   </wsdl:service>