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/10/26 10:54:12 UTC

svn commit: r467954 - /incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/

Author: mvescovi
Date: Thu Oct 26 03:54:10 2006
New Revision: 467954

URL: http://svn.apache.org/viewvc?view=rev&rev=467954
Log:
Initial refactor of <type_dcl> IDL grammar rule and its derivation rules. Still work to do on <constr_type_spec> rule and its derivations.

Added:
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitor.java   (with props)
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitorBase.java   (with props)
Modified:
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
    incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,77 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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;
+
+public class ConstrTypeSpecVisitor extends TypeSpecVisitorBase {
+
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+    
+    public ConstrTypeSpecVisitor(XmlSchemaCollection xmlSchemas,
+                                 XmlSchema xmlSchema,
+                                 TypeMappingType corbaTypeMap) {
+        super(xmlSchemas, xmlSchema, corbaTypeMap);
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;
+    }
+    
+    public static boolean accept(AST node) {
+        boolean result = 
+            StructVisitor.accept(node)
+            || UnionVisitor.accept(node)
+            || EnumVisitor.accept(node);
+        return result;
+    }
+    
+    public void visit(AST node) {
+        // <constr_type_spec> ::= <struct_type>
+        //                      | <union_type>
+        //                      | <enum_type>
+        
+        TypeSpecVisitor visitor = null;
+        
+        if (StructVisitor.accept(node)) {
+            visitor = new StructVisitor(schemas, schema, typeMap);
+        }
+
+        if (UnionVisitor.accept(node)) {
+            visitor = new UnionVisitor(schemas, schema, typeMap);
+        }
+
+        if (EnumVisitor.accept(node)) {
+            visitor = new EnumVisitor(schemas, schema, typeMap);
+        }
+
+        visitor.visit(node);
+        
+        setSchemaType(visitor.getSchemaType());
+        setCorbaType(visitor.getCorbaType());
+    }
+    
+}

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

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,65 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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.XmlSchemaType;
+
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public class DeclaratorVisitor {
+    // <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> "]"
+
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+
+    public DeclaratorVisitor(XmlSchemaCollection xmlSchemas,
+                             XmlSchema xmlSchema,
+                             TypeMappingType corbaTypeMap) {
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;    
+    }
+    
+    // REVISIT: parameter node should be the first declarator node
+    // and visit should loop through all declarators.
+    public void visit(AST node, XmlSchemaType schemaType, CorbaTypeImpl corbaType) {
+        // add schemaType
+        schema.getItems().add(schemaType);
+        schema.addType(schemaType);
+
+        // add corbaType
+        typeMap.getStructOrExceptionOrUnion().add(corbaType);
+
+    }
+    
+}

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

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java Thu Oct 26 03:54:10 2006
@@ -91,7 +91,8 @@
             break;
         }
         default: {
-            typesVisitor.visit(node);
+            TypeDclVisitor typeDclVisitor = new TypeDclVisitor(schemas, schema, typeMap, typesVisitor);
+            typeDclVisitor.visit(node);
         }
         
         }

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java Thu Oct 26 03:54:10 2006
@@ -32,12 +32,14 @@
 import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.XmlSchemaType;
 
 import org.apache.ws.commons.schema.constants.Constants;
 
 import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class EnumVisitor extends TypesVisitorBase {
+public class EnumVisitor extends TypeSpecVisitorBase {
 
     public EnumVisitor(XmlSchemaCollection xmlSchemas,
                        XmlSchema xmlSchema,
@@ -45,6 +47,13 @@
         super(xmlSchemas, xmlSchema, typeMappingType);
     }
     
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_enum) {
+            return true;
+        }
+        return false;
+    }
+    
     public void visit(AST enumNode) {
         AST enumNameNode = enumNode.getFirstChild();
 
@@ -83,11 +92,14 @@
             node = node.getNextSibling();
         }
         
-        // add xmlschema:enum
-        schema.addType(enumSchemaSimpleType);
-        schema.getItems().add(enumSchemaSimpleType);
-
-        // add corba:enum
-        typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
+        XmlSchemaType schemaType = enumSchemaSimpleType;
+        CorbaTypeImpl corbaType = corbaEnum;
+        // declaration phase
+        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(schemas, schema, typeMap);
+        declaratorVisitor.visit(node, schemaType, corbaType);
+
+        // REVISIT: are there assignments needed?
+        setSchemaType(enumSchemaSimpleType);
+        setCorbaType(corbaEnum);
     }
 }

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java Thu Oct 26 03:54:10 2006
@@ -36,7 +36,7 @@
 
 import org.apache.yoko.wsdl.CorbaConstants;
 
-public class FixedVisitor extends TypesVisitorBase {
+public class FixedVisitor extends TypeSpecVisitorBase {
 
     public FixedVisitor(XmlSchemaCollection xmlSchemas,
                        XmlSchema xmlSchema,
@@ -44,7 +44,14 @@
         super(xmlSchemas, xmlSchema, typeMappingType);
     }
     
-    public void visit(AST typedefNode) {
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_fixed) {
+            return true;
+        }
+        return false;
+    }
+    
+    public void visit(AST fixedNode) {
         //      "typedef" <type_declarator>
         //      <type_declarator> ::= <type_spec> <declarators>
         //      <type_spec> ::= <simple_type_spec>
@@ -67,7 +74,7 @@
         //      <complex_declarator> ::= <array_declarator>
         //      <array_declarator> ::= <identifier> <fixed_array_size>+
         //      <fixed_array_size> ::= "[" <positive_int_const> "]"
-        AST fixedNode = typedefNode.getFirstChild();
+        //AST fixedNode = typedefNode.getFirstChild();
         AST digitsNode = fixedNode.getFirstChild();
         AST scaleNode = digitsNode.getNextSibling();
         AST identifierNode = fixedNode.getNextSibling();
@@ -103,6 +110,8 @@
         // add xmlschema:fixed
         getSchema().getItems().add(fixedSimpleType);
         getSchema().addType(fixedSimpleType);
+        
+        setSchemaType(fixedSimpleType);
 
         
         // corba:fixed
@@ -118,5 +127,7 @@
         
         // add corba:fixed
         typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
+        
+        setCorbaType(corbaFixed);
     }
 }

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java Thu Oct 26 03:54:10 2006
@@ -19,27 +19,53 @@
 
 package org.apache.yoko.tools.processors.idl;
 
+import java.util.ArrayList;
+import java.util.List;
+
 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.XmlSchemaType;
 
-public class PrimitiveTypesVisitor extends TypesVisitorBase {
+public class PrimitiveTypesVisitor extends TypeSpecVisitorBase {
     
+    private static final List<Integer> PRIMITIVE_TYPES = new ArrayList<Integer>();
+
+    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));
+        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_any));
+    }
+
     public PrimitiveTypesVisitor(XmlSchemaCollection xmlSchemas,
                                  XmlSchema xmlSchema,
                                  TypeMappingType typeMapRef) {
         super(xmlSchemas, xmlSchema, typeMapRef);
     }
 
+    public static boolean accept(AST node) {
+        return PRIMITIVE_TYPES.contains(node.getType());
+    }
+    
     public void visit(AST node) {
-        XmlSchemaType schemaType = TypesUtils.findType(schemas, schema, node);
-        if (schemaType != null) {
-            setSchemaType(schemaType);
-            setCorbaType(TypesUtils.findCorbaType(typeMap, schemaType.getQName()));
+        // <base_type_spec> ::= ... PrimitiveVisitor
+        
+        setSchemaType(TypesUtils.findType(schemas, schema, node));
+        if (getSchemaType() != null) {
+            setCorbaType(TypesUtils.findCorbaType(typeMap, getSchemaType().getQName()));
         }
     }
+    
 }

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,57 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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;
+
+public class ScopedNameVisitor extends TypeSpecVisitorBase {
+
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+    
+    public ScopedNameVisitor(XmlSchemaCollection xmlSchemas,
+                             XmlSchema xmlSchema,
+                             TypeMappingType corbaTypeMap) {
+        super(xmlSchemas, xmlSchema, corbaTypeMap);
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;
+    }
+    
+    public static boolean accept(XmlSchemaCollection schemas, XmlSchema schema, AST node) {
+        // REVISIT
+        if (TypesUtils.findType(schemas, schema, node) != null) {
+            return true;
+        }
+        return false;
+    }
+
+    public void visit(AST node) {
+        setSchemaType(TypesUtils.findType(schemas, schema, node));
+        setCorbaType(TypesUtils.findCorbaType(typeMap, getSchemaType().getQName()));
+    }
+    
+}

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

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java Thu Oct 26 03:54:10 2006
@@ -35,7 +35,7 @@
 
 import org.apache.yoko.wsdl.CorbaConstants;
 
-public class SequenceVisitor extends TypesVisitorBase {
+public class SequenceVisitor extends TypeSpecVisitorBase {
 
     public SequenceVisitor(XmlSchemaCollection xmlSchemas,
                            XmlSchema xmlSchema,
@@ -43,8 +43,15 @@
         super(xmlSchemas, xmlSchema, typeMapRef);
     }
     
-    public void visit(AST node) {
-        AST seq = node.getFirstChild();
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_sequence) {
+            return true;
+        }
+        return false;
+    }
+    
+    public void visit(AST seq) {
+        //AST seq = node.getFirstChild();
         AST node2 = seq.getFirstChild();
         XmlSchemaType stype = TypesUtils.findType(schemas, schema, node2);
         if (stype == null) {
@@ -70,8 +77,6 @@
             el.setSchemaTypeName(stype.getQName());
             sequence.getItems().add(el);
             ct.setParticle(sequence);
-            getSchema().getItems().add(ct);
-            getSchema().addType(ct);
 
             //create the corba sequence
             Sequence corbaSeq = new Sequence();
@@ -85,8 +90,15 @@
             corbaSeq.setRepositoryID(CorbaConstants.REPO_STRING
                                      + name
                                      + CorbaConstants.IDL_VERSION);
+
+            // add xmlschema:sequence
+            getSchema().getItems().add(ct);
+            getSchema().addType(ct);
+            
+            // add corba:sequence
             getCorbaTypeMap().getStructOrExceptionOrUnion().add(corbaSeq);
-            setSchemaType(ct);
+            
+            setSchemaType(ct); 
             setCorbaType(corbaSeq);
         }
     }

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,80 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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;
+
+public class SimpleTypeSpecVisitor extends TypeSpecVisitorBase {
+
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+    
+    public SimpleTypeSpecVisitor(XmlSchemaCollection xmlSchemas,
+                                 XmlSchema xmlSchema,
+                                 TypeMappingType corbaTypeMap) {
+        super(xmlSchemas, xmlSchema, corbaTypeMap);
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;
+    }
+
+    public static boolean accept(AST node) {
+        boolean result = 
+            PrimitiveTypesVisitor.accept(node)
+            || TemplateTypeSpecVisitor.accept(node);
+        return result;
+    }
+    
+    public void visit(AST node) {
+        // <simple_type_spec> ::= <base_type_spec>
+        //                      | <template_type_spec>
+        //                      | <scoped_name>
+
+        
+        TypeSpecVisitor visitor = null;
+        
+        // simple_type_spec - base_type_spec
+        if (PrimitiveTypesVisitor.accept(node)) {
+            visitor = new PrimitiveTypesVisitor(schemas, schema, typeMap);
+        }
+
+        // simple_type_spec - template_type_spec
+        if (TemplateTypeSpecVisitor.accept(node)) {
+            visitor = new TemplateTypeSpecVisitor(schemas, schema, typeMap);
+        }
+        
+        // simple_type_spec - scoped_name
+        if (ScopedNameVisitor.accept(schemas, schema, node)) {
+            visitor = new ScopedNameVisitor(schemas, schema, typeMap);
+        }
+        
+        
+        visitor.visit(node);
+
+        setSchemaType(visitor.getSchemaType());
+        setCorbaType(visitor.getCorbaType());
+    }
+}

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

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java Thu Oct 26 03:54:10 2006
@@ -39,7 +39,7 @@
 import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class StringVisitor extends TypesVisitorBase {
+public class StringVisitor extends TypeSpecVisitorBase {
 
     private AST stringNode;
     private AST boundNode;
@@ -56,8 +56,19 @@
         stringName = null;
     }
 
-    public void visit(AST typedefNode) {
-        stringNode = typedefNode.getFirstChild();
+    public static boolean accept(AST node) {
+        if ((node.getType() == IDLTokenTypes.LITERAL_string) 
+            || (node.getType() == IDLTokenTypes.LITERAL_wstring)) {
+            return true;
+        }
+        return false;
+    }
+    
+    public void visit(AST node) {
+        // <string_type> ::= "string" "<" <positive_int_const> ">"
+        //                 | "string"
+        
+        stringNode = node;
         boundNode = stringNode.getFirstChild();
         typeNameNode = stringNode.getNextSibling();
         stringName = new String(typeNameNode.toString());
@@ -81,10 +92,9 @@
         maxLengthFacet.setValue(boundNode.toString());
         restriction.getFacets().add(maxLengthFacet);
         simpleType.setContent(restriction);
-        
-        // add xmlschema:simpleType
-        getSchema().getItems().add(simpleType);
-        getSchema().addType(simpleType);
+
+        // xmlschema:simpleType
+        setSchemaType(simpleType);
         
         
         String anonstringName = new String("_1_" + stringName);
@@ -128,43 +138,53 @@
                               + CorbaConstants.IDL_VERSION);
         
         // add corba:alias
-        typeMap.getStructOrExceptionOrUnion().add(alias);
-
+        setCorbaType(alias);
     }
     
     private void visitUnboundedString() {
         // REVISIT: code in this block is very similar to TypedefVisitor.visitAlias() method
         
-        // xmlschema:simpleType
-        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
-        simpleType.setName(stringName);
-        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
-        restriction.setBaseTypeName(Constants.XSD_STRING);
-        simpleType.setContent(restriction);
-        
-        // add xmlschema:simpleType
-        getSchema().getItems().add(simpleType);
-        getSchema().addType(simpleType);
-        
-        
-        // corba:alias
-        Alias alias = new Alias();
-        alias.setQName(new QName(typeMap.getTargetNamespace(), stringName));
+//        // xmlschema:simpleType
+//        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+//        simpleType.setName(stringName);
+//        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+//        restriction.setBaseTypeName(Constants.XSD_STRING);
+//        simpleType.setContent(restriction);
+//        
+//        // add xmlschema:simpleType
+//        setSchemaType(simpleType);
+        setSchemaType(schemas.getTypeByQName(Constants.XSD_STRING));
+        
+//        // corba:alias
+//        Alias alias = new Alias();
+//        alias.setQName(new QName(typeMap.getTargetNamespace(), stringName));
+//        if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
+//            alias.setBasetype(CorbaConstants.NT_CORBA_STRING);
+//        } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
+//            alias.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
+//        } else { 
+//            // should never get here
+//            throw new RuntimeException("StringVisitor attempted to visit an invalid node");
+//        }
+//        alias.setType(Constants.XSD_STRING);
+//        alias.setRepositoryID(CorbaConstants.REPO_STRING
+//                              + stringName
+//                              + CorbaConstants.IDL_VERSION);
+//        
+//        // add corba:alias
+//        setCorbaType(alias);
+        CorbaTypeImpl corbaString = new CorbaTypeImpl();
         if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
-            alias.setBasetype(CorbaConstants.NT_CORBA_STRING);
+            corbaString.setQName(CorbaConstants.NT_CORBA_STRING);
         } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
-            alias.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
+            corbaString.setQName(CorbaConstants.NT_CORBA_WSTRING);
         } else { 
             // should never get here
             throw new RuntimeException("StringVisitor attempted to visit an invalid node");
         }
-        alias.setType(Constants.XSD_STRING);
-        alias.setRepositoryID(CorbaConstants.REPO_STRING
-                              + stringName
-                              + CorbaConstants.IDL_VERSION);
-        
-        // add corba:alias
-        typeMap.getStructOrExceptionOrUnion().add(alias);
+        corbaString.setName(Constants.XSD_STRING.getLocalPart());
+        corbaString.setType(Constants.XSD_STRING);
+        setCorbaType(corbaString);
 
     }
     

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java Thu Oct 26 03:54:10 2006
@@ -35,8 +35,9 @@
 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 TypeSpecVisitorBase {
     
     public StructVisitor(XmlSchemaCollection xmlSchemas,
                          XmlSchema xmlSchema,
@@ -44,6 +45,13 @@
         super(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();
         
@@ -92,14 +100,13 @@
             memberTypeNode = memberNode.getNextSibling();
         }
 
+        XmlSchemaType schemaType = complexType;
+        CorbaTypeImpl corbaType = struct;
+        // declaration phase
+        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(schemas, schema, typeMap);
+        declaratorVisitor.visit(structNode, schemaType, corbaType);
 
-        // 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);
     }

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,77 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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;
+
+public class TemplateTypeSpecVisitor extends TypeSpecVisitorBase {
+
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+    
+    public TemplateTypeSpecVisitor(XmlSchemaCollection xmlSchemas,
+                                   XmlSchema xmlSchema,
+                                   TypeMappingType corbaTypeMap) {
+        super(xmlSchemas, xmlSchema, corbaTypeMap);
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;
+    }
+
+    public static boolean accept(AST node) {
+        boolean result = 
+            SequenceVisitor.accept(node)
+            || StringVisitor.accept(node)
+            || FixedVisitor.accept(node);
+        return result;
+    }
+    
+    public void visit(AST node) {
+        // <template_type_spec> ::= <sequence_type>
+        //                        | <string_type>
+        //                        | <wide_string_type>
+        //                        | <fixed_pt_type>
+
+
+        TypeSpecVisitor visitor = null;
+        
+        if (SequenceVisitor.accept(node)) {
+            visitor = new SequenceVisitor(schemas, schema, typeMap);
+        }
+        if (StringVisitor.accept(node)) {
+            visitor = new StringVisitor(schemas, schema, typeMap);
+        }
+        if (FixedVisitor.accept(node)) {
+            visitor = new FixedVisitor(schemas, schema, typeMap);
+        }
+
+        visitor.visit(node);
+
+        setSchemaType(visitor.getSchemaType());
+        setCorbaType(visitor.getCorbaType());
+    }
+
+}

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

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,81 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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;
+
+public class TypeDclVisitor {
+
+//    private Definition definition;
+    private XmlSchemaCollection schemas;
+    private XmlSchema schema;
+    private TypeMappingType typeMap;
+    private TypesVisitor typesVisitor;
+    
+    public TypeDclVisitor(XmlSchemaCollection xmlSchemas,
+                          XmlSchema xmlSchema,
+                          TypeMappingType corbaTypeMap,
+                          TypesVisitor typesVisitorRef) {
+//        definition = wsdlDefinition;
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = corbaTypeMap;
+        typesVisitor = typesVisitorRef;
+    }
+    
+    public void visit(AST node) {
+        // <type_dcl> ::= "typedef" <type_declarator>
+        //              | <struct_type>
+        //              | <union_type>
+        //              | <enum_type>
+        //              | "native" <simple_declarator>
+        //              | <constr_forward_decl>
+
+        TypeSpecVisitor visitor = null;
+        
+        if (TypedefVisitor.accept(node)) {
+            visitor = new TypedefVisitor(schemas, schema, typeMap, typesVisitor);
+        }
+        
+        if (StructVisitor.accept(node)) {
+            visitor = new StructVisitor(schemas, schema, typeMap);
+        }
+        
+        if (UnionVisitor.accept(node)) {
+            visitor = new UnionVisitor(schemas, schema, typeMap);
+        }
+        
+        if (EnumVisitor.accept(node)) {
+            visitor = new EnumVisitor(schemas, schema, typeMap);
+        }
+        
+        // native type not supported
+        
+        // TBD: forward declaration <constr_forward_declaration>
+        
+        visitor.visit(node);
+    }
+
+}

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

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitor.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitor.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitor.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,34 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+import antlr.collections.AST;
+
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public interface TypeSpecVisitor {
+    
+    void visit(AST node);
+    
+    XmlSchemaType getSchemaType();
+    CorbaTypeImpl getCorbaType();
+}

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

Added: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitorBase.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitorBase.java?view=auto&rev=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitorBase.java (added)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeSpecVisitorBase.java Thu Oct 26 03:54:10 2006
@@ -0,0 +1,89 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+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.XmlSchemaType;
+
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public abstract class TypeSpecVisitorBase implements TypeSpecVisitor {
+
+    protected XmlSchema schema;
+    protected XmlSchemaCollection schemas;
+    protected TypeMappingType typeMap;
+
+    private XmlSchemaType schemaType;
+    private CorbaTypeImpl corbaType;
+    
+    public TypeSpecVisitorBase(XmlSchemaCollection xmlSchemas,
+                               XmlSchema xmlSchema,
+                               TypeMappingType typeMapRef) {
+        schemas = xmlSchemas;
+        schema = xmlSchema;
+        typeMap = typeMapRef;
+        
+        schemaType = null;
+        corbaType = null;
+    }
+
+    public abstract void visit(AST node);
+    
+    // REVISIT: what's the point of getter method for protected member?
+    public XmlSchema getSchema() {
+        return schema;
+    }
+    
+    // REVISIT: what's the point of getter method for protected member?
+    public TypeMappingType getCorbaTypeMap() {
+        return typeMap;
+    }
+    
+    protected void setSchemaType(XmlSchemaType type) {
+        schemaType = type;
+    }
+    
+    public XmlSchemaType getSchemaType() {
+        if (schemaType == null) {
+            throw new RuntimeException("Schema type is null! "
+                                       + "Method visit() must be called before getSchemaType()");
+        }
+        return schemaType;
+    }
+    
+    protected void setCorbaType(CorbaTypeImpl type) {
+        corbaType = type;
+    }
+    
+    public CorbaTypeImpl getCorbaType() {
+        if (corbaType == null) {
+            throw new RuntimeException("Corba type is null! "
+                                       + "Method visit() must be called before getCorbaType()");
+        }
+        return corbaType;        
+    }
+    
+
+}

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

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java Thu Oct 26 03:54:10 2006
@@ -31,234 +31,84 @@
 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.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-    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;
+public class TypedefVisitor extends TypeSpecVisitorBase {
 
+    private TypesVisitor typesVisitor;
     
     public TypedefVisitor(XmlSchemaCollection xmlSchemas,
                           XmlSchema xmlSchema,
-                          TypeMappingType typeMappingType) {
+                          TypeMappingType typeMappingType,
+                          TypesVisitor typesVisitorRef) {
         super(xmlSchemas, xmlSchema, typeMappingType);
+        typesVisitor = typesVisitorRef;
     }
     
-    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 SequenceVisitor(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;
-        }
-    }
-    
-    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;
-    }
-
-    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;
-    }
-
-    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;
-    }
-
-    private boolean isWString(AST node) {
-        boolean result = false;
+    public static boolean accept(AST node) {
         if (node.getType() == IDLTokenTypes.LITERAL_typedef) {
-            AST node2 = node.getFirstChild();
-            if (node2.getType() == IDLTokenTypes.LITERAL_wstring) {                
-                result = true;
-            }
+            return true;
         }
-        return result;
+        return false;
     }
+    
+    public void visit(AST typedefNode) {
+        // "typedef" <type_declarator>
+        // <type_declarator> ::= <type_spec> <declarators>
 
-    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;
-    }
+        AST typeDeclaratorNode = typedefNode.getFirstChild(); 
+        typesVisitor.visit(typeDeclaratorNode);
 
-    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;
-            }
+        XmlSchemaType schemaType = typesVisitor.getSchemaType();
+        CorbaTypeImpl corbaType = typesVisitor.getCorbaType();
+        
+        // Handle cases "typedef sequence"
+        //              "typedef fixed"
+        boolean doAlias =
+            SequenceVisitor.accept(typeDeclaratorNode)
+            || FixedVisitor.accept(typeDeclaratorNode);
+        if (!doAlias) {
+            generateAlias(TypesUtils.getPrimitiveCorbaTypeNameNode(typedefNode.getFirstChild()),
+                          //typedefNode.getFirstChild().getNextSibling(),
+                          schemaType,
+                          corbaType);
+
+            // declaration phase
+            schemaType = getSchemaType();
+            corbaType = getCorbaType();
+            DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(schemas, schema, typeMap);
+            declaratorVisitor.visit(typedefNode.getFirstChild().getNextSibling(),
+                                    schemaType,
+                                    corbaType);
         }
-        return result;                
     }
     
-    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());
+        simpleType.setName(identifierNode.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(), identifierNode.toString()));
+        alias.setBasetype(corbaType.getQName());
+        alias.setType(schemaType.getQName());
         alias.setRepositoryID(CorbaConstants.REPO_STRING
-                              + typeNameNode.toString()
+                              + identifierNode.toString()
                               + CorbaConstants.IDL_VERSION);
         
         // add corba:alias
-        typeMap.getStructOrExceptionOrUnion().add(alias);
+        setCorbaType(alias);
     }
 }

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java Thu Oct 26 03:54:10 2006
@@ -26,11 +26,9 @@
 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;
@@ -43,19 +41,14 @@
 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.yoko.wsdl.CorbaTypeImpl;
-
-public class TypesVisitor implements ASTVisitor {
+public class TypesVisitor extends TypeSpecVisitorBase {
     
-    static final List<Integer> PRIMITIVE_TYPES = new ArrayList<Integer>();
     static final int PRIMITIVE = 0;
 
     TypeMappingType typeMap;
 
     Definition definition;
-    WSDLFactory wsdlFactory;
     
     XmlSchema schema;
     XmlSchemaCollection schemas;
@@ -65,11 +58,12 @@
 
     List<String> parts = new ArrayList<String>();
 
-    public TypesVisitor(Definition wsdlDefinition,
-                        XmlSchemaCollection xmlSchemas,
+    public TypesVisitor(XmlSchemaCollection xmlSchemas,
                         XmlSchema xmlSchema,
-                        TypeMappingType corbaTypeMap)
+                        TypeMappingType corbaTypeMap,
+                        Definition wsdlDefinition)
         throws WSDLException {
+        super(xmlSchemas, xmlSchema, corbaTypeMap);
         definition = wsdlDefinition;
         schema = xmlSchema;
         schemas = xmlSchemas;
@@ -147,88 +141,43 @@
     }
 
     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();
+        TypeSpecVisitor visitor = null;
+        
+        // type_spec - constr_type_spec
+        if (ConstrTypeSpecVisitor.accept(node)) {
+            visitor = new ConstrTypeSpecVisitor(schemas, schema, typeMap);
+        }
+
+        // type_spec - simple_type_spec
+        if (SimpleTypeSpecVisitor.accept(node)) {
+            visitor = new SimpleTypeSpecVisitor(schemas, schema, typeMap);
+        }
+                
+
+        // 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!!!
+        if (visitor == null) {
+            visitor = new ScopedNameVisitor(schemas, schema, typeMap);
         }
-    }
-
-    private boolean isPrimitive(int nodeType) {
-        return PRIMITIVE_TYPES.contains(nodeType);
-    }
+        
+        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));
-        PRIMITIVE_TYPES.add(new Integer(IDLTokenTypes.LITERAL_any));
+        setSchemaType(visitor.getSchemaType());
+        setCorbaType(visitor.getCorbaType());
+        
     }
 
 }

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java Thu Oct 26 03:54:10 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/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java Thu Oct 26 03:54:10 2006
@@ -37,8 +37,9 @@
 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 TypeSpecVisitorBase {
 
     private final String discriminator = "discriminator";
     
@@ -48,6 +49,13 @@
         super(xmlSchemas, xmlSchema, typeMappingType);
     }
     
+    public static boolean accept(AST node) {
+        if (node.getType() == IDLTokenTypes.LITERAL_union) {
+            return true;
+        }
+        return false;
+    }
+    
     public void visit(AST unionNode) {
         AST identifierNode = unionNode.getFirstChild();
         AST discriminatorNode = identifierNode.getNextSibling();
@@ -85,12 +93,15 @@
         processCaseNodes(caseNode, choice, corbaUnion);
             
         
-        // add xmlschema:union
-        schema.getItems().add(unionSchemaComplexType);
-        schema.addType(unionSchemaComplexType);
+        XmlSchemaType schemaType = unionSchemaComplexType;
+        CorbaTypeImpl corbaType = corbaUnion;
+        // declaration phase
+        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(schemas, schema, typeMap);
+        declaratorVisitor.visit(identifierNode, schemaType, corbaType);
 
-        // add corba:union
-        typeMap.getStructOrExceptionOrUnion().add(corbaUnion);
+        // REVISIT: are these assignments needed?
+        setSchemaType(unionSchemaComplexType);
+        setCorbaType(corbaUnion);
     }
     
     private void processCaseNodes(AST caseNode,

Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java?view=diff&rev=467954&r1=467953&r2=467954
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java Thu Oct 26 03:54:10 2006
@@ -73,7 +73,7 @@
         
         createCorbaTypeMap();
         
-        typesVisitor = new TypesVisitor(definition, schemas, schema, typeMap);
+        typesVisitor = new TypesVisitor(schemas, schema, typeMap, definition);
     }
 
     public void visit(AST node) {