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 [1/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/
Author: mvescovi
Date: Tue Nov 28 07:42:24 2006
New Revision: 480098
URL: http://svn.apache.org/viewvc?view=rev&rev=480098
Log:
YOKO-206 Merging idltowsdl_anon_refactor branch to trunk
Added:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java (contents, props changed)
- copied, changed from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (contents, props changed)
- copied, changed from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java (contents, props changed)
- copied, changed from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TemplateTypeSpecVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypeDclVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Visitor.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Visitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/VisitorBase.java (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/VisitorBase.java
incubator/yoko/trunk/tools/src/test/resources/idl/Anonarray.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonarray.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Anonboundedsequence.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonboundedsequence.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Anonsequence.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonsequence.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Anonstring.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonstring.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Array.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Array.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Sequence.idl
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Sequence.idl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonarray.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonarray.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonboundedsequence.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonboundedsequence.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonsequence.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonsequence.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Anonstring.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonstring.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Array.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Array.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Sequence.wsdl (props changed)
- copied unchanged from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Sequence.wsdl
Removed:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java
Modified:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/AttributeVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitorBase.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl
incubator/yoko/trunk/tools/src/test/resources/idl/Typedef.idl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Attributes.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Const.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Exception.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Fixed.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_String.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Struct.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Typedef.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Union.wsdl
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/AttributeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/AttributeVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/AttributeVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/AttributeVisitor.java Tue Nov 28 07:42:24 2006
@@ -35,7 +35,6 @@
import javax.xml.namespace.QName;
-import antlr.ASTVisitor;
import antlr.collections.AST;
import org.apache.schemas.yoko.bindings.corba.ArgType;
@@ -54,7 +53,7 @@
import org.apache.yoko.wsdl.CorbaConstants;
import org.apache.yoko.wsdl.CorbaTypeImpl;
-public class AttributeVisitor implements ASTVisitor {
+public class AttributeVisitor extends VisitorBase {
private static final String GETTER_PREFIX = "_get_";
private static final String SETTER_PREFIX = "_set_";
@@ -64,32 +63,38 @@
private static final String PARAM_NAME = "_arg";
private static final String RETURN_PARAM_NAME = "return";
- private WSDLASTVisitor wsdlASTVisitor;
- private XmlSchema schema;
- private XmlSchemaCollection schemas;
- private TypeMappingType typeMap;
private Definition definition;
private ExtensionRegistry extReg;
private PortType portType;
private Binding binding;
- public AttributeVisitor(WSDLASTVisitor visitor,
+ public AttributeVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType typeMap,
+ Definition wsdlDefinition,
PortType wsdlPortType,
Binding wsdlBinding) {
- wsdlASTVisitor = visitor;
- // REVISIT: there has to be a better way to access schema and schemas
- TypesVisitor typesVisitor = wsdlASTVisitor.getTypesVisitor();
- schema = typesVisitor.getSchema();
- schemas = typesVisitor.getSchemas();
- typeMap = typesVisitor.getCorbaTypeMapping();
- //
- definition = visitor.getDefinition();
+ super(scope, xmlSchemas, xmlSchema, typeMap);
+ definition = wsdlDefinition;
extReg = definition.getExtensionRegistry();
portType = wsdlPortType;
binding = wsdlBinding;
}
+ public static boolean accept(AST node) {
+ if (node.getType() == IDLTokenTypes.LITERAL_readonly
+ || node.getType() == IDLTokenTypes.LITERAL_attribute) {
+ return true;
+ }
+ return false;
+ }
+
public void visit(AST attributeNode) {
+ // <attr_dcl> ::= ["readonly"] "attribute" <param_type_spec> <simple_declarator>
+ // {"," <simple_declarator>}*
+
+
AST node = attributeNode.getFirstChild();
AST readonlyNode = null;
@@ -121,7 +126,7 @@
PARAM_NAME);
// generate wrapped doc element out parameter
XmlSchemaElement outParameters =
- generateWrappedDocElement(typeNode,
+ generateWrappedDocElement(typeNode,
GETTER_PREFIX + nameNode.toString() + RESULT_POSTFIX,
RETURN_PARAM_NAME);
@@ -210,8 +215,11 @@
private XmlSchemaElement generateWrappedDocElement(AST typeNode, String name, String paramName) {
XmlSchemaElement element = new XmlSchemaElement();
if (typeNode != null) {
- //element.setSchemaType(TypesUtils.findType(schemas, schema, typeNode));
- element.setSchemaTypeName(TypesUtils.findType(schemas, schema, typeNode).getQName());
+ ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), schemas, schema, typeMap);
+ visitor.visit(typeNode);
+ XmlSchemaType stype = visitor.getSchemaType();
+
+ element.setSchemaTypeName(stype.getQName());
element.setName(paramName);
}
@@ -273,8 +281,9 @@
ArgType param = new ArgType();
param.setName(RETURN_PARAM_NAME);
- XmlSchemaType stype = TypesUtils.findType(schemas, schema, type);
- CorbaTypeImpl corbaType = TypesUtils.findCorbaType(typeMap, stype.getQName());
+ ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), schemas, schema, typeMap);
+ visitor.visit(type);
+ CorbaTypeImpl corbaType = visitor.getCorbaType();
param.setIdltype(corbaType.getQName());
@@ -286,8 +295,9 @@
param.setName(PARAM_NAME);
param.setMode(ModeType.IN);
- XmlSchemaType stype = TypesUtils.findType(schemas, schema, type);
- CorbaTypeImpl corbaType = TypesUtils.findCorbaType(typeMap, stype.getQName());
+ ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), schemas, schema, typeMap);
+ visitor.visit(type);
+ CorbaTypeImpl corbaType = visitor.getCorbaType();
param.setIdltype(corbaType.getQName());
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java Tue Nov 28 07:42:24 2006
@@ -30,15 +30,38 @@
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaType;
-public class ConstVisitor extends TypesVisitorBase {
+import org.apache.yoko.wsdl.CorbaTypeImpl;
- public ConstVisitor(XmlSchemaCollection xmlSchemas,
+public class ConstVisitor extends VisitorBase {
+
+ public ConstVisitor(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_const) {
+ return true;
+ }
+ return false;
}
public void visit(AST constNode) {
+ // <const_dcl> ::= "const" <const_type> <identifier> "=" <const_exp>
+ // <const_type> ::= <integer_type>
+ // | <char_type>
+ // | <wide_char_type>
+ // | <boolean_type>
+ // | <floating_pt_type>
+ // | <string_type>
+ // | <wide_string_type>
+ // | <fixed_pt_const_type>
+ // | <scoped_name>
+ // | <octet_type>
+
+
AST constTypeNode = constNode.getFirstChild();
AST constNameNode = TypesUtils.getPrimitiveCorbaTypeNameNode(constTypeNode);
AST constValueNode = constNameNode.getNextSibling();
@@ -52,25 +75,22 @@
}
QName constQName = new QName(typeMap.getTargetNamespace(),
- constNameNode.toString());
-
- // xsd::schemaType
- XmlSchemaType constSchemaType = TypesUtils.findType(schemas, schema, constTypeNode);
-
- // corba:type
- //// There is a problem with retrieving the corba:type from a schema:type
- // the schema:type -> corba:type is not one-to-one
- //CorbaTypeImpl constCorbaType = TypesUtils.findCorbaType(typeMap, constSchemaType.getQName());
+ new Scope(getScope(), constNameNode).toString());
- // const types are guaranteed to be primitive types
- QName constCorbaTypeName = TypesUtils.findCorbaTypeName(typeMap, constTypeNode);
+ // TEMPORARILY
+ // using TypesVisitor to visit <const_type>
+ // it should be visited by a ConstTypeVisitor
+ TypesVisitor visitor = new TypesVisitor(getScope(), schemas, schema, typeMap, constNameNode);
+ visitor.visit(constTypeNode);
+ XmlSchemaType constSchemaType = visitor.getSchemaType();
+ CorbaTypeImpl constCorbaType = visitor.getCorbaType();
+ QName constCorbaTypeName = constCorbaType.getQName();
// corba:const
Const corbaConst = new Const();
corbaConst.setQName(constQName);
corbaConst.setValue(constValue);
corbaConst.setType(constSchemaType.getQName());
- //corbaConst.setIdltype(constCorbaType.getQName());
corbaConst.setIdltype(constCorbaTypeName);
typeMap.getStructOrExceptionOrUnion().add(corbaConst);
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstrTypeSpecVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DefinitionVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java Tue Nov 28 07:42:24 2006
@@ -32,25 +32,40 @@
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 VisitorBase {
- public EnumVisitor(XmlSchemaCollection xmlSchemas,
+ public EnumVisitor(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_enum) {
+ return true;
+ }
+ return false;
}
public void visit(AST enumNode) {
+ // <enum_type> ::= "enum" <identifier> "{" <enumerator> {"," <enumerator>}* "}"
+ // <enumerator> ::= <identifier>
+
+
AST enumNameNode = enumNode.getFirstChild();
+ Scope enumNameScope = new Scope(getScope(), enumNameNode);
// xmlschema:enum
XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema);
- enumSchemaSimpleType.setName(enumNameNode.toString());
+ enumSchemaSimpleType.setName(enumNameScope.toString());
XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
@@ -61,9 +76,9 @@
// corba:enum
Enum corbaEnum = new Enum();
- corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameNode.toString()));
+ corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString()));
corbaEnum.setRepositoryID(CorbaConstants.REPO_STRING
- + enumNameNode.toString()
+ + enumNameScope.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
corbaEnum.setType(enumSchemaSimpleType.getQName());
@@ -83,11 +98,19 @@
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(getScope(),
+ schemas,
+ schema,
+ typeMap,
+ schemaType,
+ corbaType);
+ declaratorVisitor.visit(enumNameNode);
+
+ // REVISIT: are there assignments needed?
+ setSchemaType(enumSchemaSimpleType);
+ setCorbaType(corbaEnum);
}
}
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java Tue Nov 28 07:42:24 2006
@@ -35,25 +35,53 @@
import org.apache.ws.commons.schema.XmlSchemaType;
import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
-public class ExceptionVisitor extends TypesVisitorBase {
+public class ExceptionVisitor extends VisitorBase {
- public ExceptionVisitor(XmlSchemaCollection xmlSchemas,
- XmlSchema xmlSchema,
- TypeMappingType typeMappingType) {
- super(xmlSchemas, xmlSchema, typeMappingType);
+ private static final String TYPE_SUFFIX = "Type";
+
+ public ExceptionVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType typeMappingType) {
+ super(scope, xmlSchemas, xmlSchema, typeMappingType);
}
+ public static boolean accept(AST node) {
+ if (node.getType() == IDLTokenTypes.LITERAL_exception) {
+ return true;
+ }
+ return false;
+ }
+
public void visit(AST node) {
- AST structNode = node.getFirstChild();
+ // <exception_dcl> ::= "exception" <identifier> "{" <member>* "}"
+ // <member> ::= <type_spec> <declarators> ";"
+
+ // <type_spec> visited by TypesVisitor
+
+ // Following should be visited by a separate visitor
+ // <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 identifierNode = node.getFirstChild();
+ Scope exceptionScope = new Scope(getScope(), identifierNode);
// xmlschema:exception
- String exceptionName = structNode.toString();
+ Scope scopedName = new Scope(getScope(), identifierNode);
+ String exceptionName = scopedName.toString();
XmlSchemaElement element = new XmlSchemaElement();
element.setName(exceptionName);
element.setQName(new QName(schema.getTargetNamespace(), exceptionName));
- String exceptionTypeName = exceptionName + "Type";
+ String exceptionTypeName = exceptionName + TYPE_SUFFIX;
XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema);
complexType.setName(exceptionTypeName);
@@ -68,23 +96,46 @@
exception.setQName(new QName(typeMap.getTargetNamespace(), exceptionName));
exception.setType(complexType.getQName());
exception.setRepositoryID(CorbaConstants.REPO_STRING
- + exceptionName
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
// exception members
- AST memberTypeNode = structNode.getNextSibling();
+ AST memberTypeNode = identifierNode.getNextSibling();
while (memberTypeNode != null) {
AST memberNode = memberTypeNode.getNextSibling();
+ TypesVisitor visitor = new TypesVisitor(exceptionScope,
+ schemas,
+ schema,
+ typeMap,
+ null);
+ visitor.visit(memberTypeNode);
+ XmlSchemaType stype = visitor.getSchemaType();
+ CorbaTypeImpl ctype = visitor.getCorbaType();
+
+ // needed for anonymous arrays in exceptions
+ if (ArrayVisitor.accept(memberNode)) {
+ Scope anonScope = new Scope(exceptionScope,
+ TypesUtils.getPrimitiveCorbaTypeNameNode(memberTypeNode));
+ ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
+ schemas,
+ schema,
+ typeMap,
+ stype,
+ ctype,
+ null);
+ arrayVisitor.visit(memberNode);
+ stype = arrayVisitor.getSchemaType();
+ ctype = 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(stype);
+ member.setSchemaTypeName(stype.getQName());
sequence.getItems().add(member);
@@ -92,8 +143,7 @@
// corba:member
MemberType memberType = new MemberType();
memberType.setName(memberName);
- QName idlType = TypesUtils.findCorbaType(typeMap, type.getQName()).getQName();
- memberType.setIdltype(idlType);
+ memberType.setIdltype(ctype.getQName());
exception.getMember().add(memberType);
@@ -106,7 +156,6 @@
// add exception to corba typemap
- TypeMappingType typeMap = getCorbaTypeMap();
typeMap.getStructOrExceptionOrUnion().add(exception);
setSchemaType(complexType);
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java Tue Nov 28 07:42:24 2006
@@ -36,15 +36,27 @@
import org.apache.yoko.wsdl.CorbaConstants;
-public class FixedVisitor extends TypesVisitorBase {
+public class FixedVisitor extends VisitorBase {
- public FixedVisitor(XmlSchemaCollection xmlSchemas,
- XmlSchema xmlSchema,
- TypeMappingType typeMappingType) {
- super(xmlSchemas, xmlSchema, typeMappingType);
+ private AST identifierNode;
+
+ public FixedVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType typeMappingType,
+ AST identifierNodeRef) {
+ super(scope, xmlSchemas, xmlSchema, typeMappingType);
+ identifierNode = identifierNodeRef;
+ }
+
+ public static boolean accept(AST node) {
+ if (node.getType() == IDLTokenTypes.LITERAL_fixed) {
+ return true;
+ }
+ return false;
}
- public void visit(AST typedefNode) {
+ public void visit(AST fixedNode) {
// "typedef" <type_declarator>
// <type_declarator> ::= <type_spec> <declarators>
// <type_spec> ::= <simple_type_spec>
@@ -67,10 +79,11 @@
// <complex_declarator> ::= <array_declarator>
// <array_declarator> ::= <identifier> <fixed_array_size>+
// <fixed_array_size> ::= "[" <positive_int_const> "]"
- AST fixedNode = typedefNode.getFirstChild();
+
+
AST digitsNode = fixedNode.getFirstChild();
AST scaleNode = digitsNode.getNextSibling();
- AST identifierNode = fixedNode.getNextSibling();
+ Scope scopedName = new Scope(getScope(), identifierNode);
// validate digits and scale
Long digits = new Long(digitsNode.toString());
@@ -97,26 +110,25 @@
fixedFractionDigits.setFixed(true);
fixedRestriction.getFacets().add(fixedTotalDigits);
fixedRestriction.getFacets().add(fixedFractionDigits);
- fixedSimpleType.setName(identifierNode.toString());
+ fixedSimpleType.setName(scopedName.toString());
fixedSimpleType.setContent(fixedRestriction);
// add xmlschema:fixed
- getSchema().getItems().add(fixedSimpleType);
- getSchema().addType(fixedSimpleType);
+ setSchemaType(fixedSimpleType);
// corba:fixed
Fixed corbaFixed = new Fixed();
- corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), identifierNode.toString()));
+ corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
corbaFixed.setDigits(digits);
corbaFixed.setScale(scale);
corbaFixed.setRepositoryID(CorbaConstants.REPO_STRING
- + identifierNode.toString()
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
//corbaFixed.setType(Constants.XSD_DECIMAL);
corbaFixed.setType(fixedSimpleType.getQName());
// add corba:fixed
- typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
+ setCorbaType(corbaFixed);
}
}
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java Tue Nov 28 07:42:24 2006
@@ -67,6 +67,8 @@
parser.specification();
AST idlTree = parser.getAST();
+ System.out.println(idlTree.toStringTree());
+
Object obj = env.get(ToolConstants.CFG_OUTPUTDIR);
String outputDir = ".";
if (obj != null) {
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java Tue Nov 28 07:42:24 2006
@@ -20,75 +20,357 @@
package org.apache.yoko.tools.processors.idl;
import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
import javax.wsdl.PortType;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensionRegistry;
+import javax.xml.namespace.QName;
-import antlr.ASTVisitor;
import antlr.collections.AST;
+import org.apache.schemas.yoko.bindings.corba.ArgType;
import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
+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.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
-public class OperationVisitor implements ASTVisitor {
+public class OperationVisitor extends VisitorBase {
- private WSDLASTVisitor wsdlASTVisitor;
+ private static final String REQUEST_SUFFIX = "Request";
+ private static final String RESPONSE_SUFFIX = "Response";
+
+ private static final String IN_PARAMETER = "inparameter";
+ private static final String OUT_PARAMETER = "outparameter";
+ private static final String INOUT_PARAMETER = "inoutparameter";
+ private static final String RETURN_PARAMETER = "return";
+
private Definition definition;
private ExtensionRegistry extReg;
private PortType portType;
private Binding binding;
- public OperationVisitor(WSDLASTVisitor visitor,
+ private Message inputMsg;
+ private Message outputMsg;
+
+ private Part inputPart;
+ private Part outputPart;
+
+ private OperationType corbaOperation;
+
+ public OperationVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType typeMapRef,
+ Definition wsdlDefinition,
PortType wsdlPortType,
Binding wsdlBinding) {
- wsdlASTVisitor = visitor;
- definition = visitor.getDefinition();
+ super(scope, xmlSchemas, xmlSchema, typeMapRef);
+ definition = wsdlDefinition;
extReg = definition.getExtensionRegistry();
portType = wsdlPortType;
binding = wsdlBinding;
}
- public void visit(AST node) {
- MessageVisitor msgVisitor = new MessageVisitor(wsdlASTVisitor);
- Operation op = definition.createOperation();
- op.setName(node.toString());
- op.setUndefined(false);
- portType.addOperation(op);
- BindingOperation bindingOperation = createBindingOperation(binding, op);
- msgVisitor.setOperation(op);
- msgVisitor.setBindingOperation(bindingOperation);
+ public static boolean accept(Scope scope, XmlSchemaCollection schemas, XmlSchema schema,
+ TypeMappingType typeMap, AST node) {
+ boolean result = false;
AST node2 = node.getFirstChild();
- if (node2 != null && node2.getType() == IDLTokenTypes.LITERAL_oneway) {
- // oneway operations map to operations with input message
- msgVisitor.createInputMessage();
+ if (node2.getType() == IDLTokenTypes.LITERAL_oneway) {
+ result = true;
+ } else {
+ int type = node2.getType();
+ result =
+ type == IDLTokenTypes.LITERAL_void
+ || PrimitiveTypesVisitor.accept(node2)
+ || StringVisitor.accept(node2)
+ || ScopedNameVisitor.accept(scope, schemas, schema, typeMap, node2);
+ }
+ return result;
+ }
+
+ public void visit(AST node) {
+ // <op_dcl> ::= [<op_attribute>] <op_type_spec>
+ // <identifier> <parameter_dcls>
+ // [<raises_expr>] [<context_expr>]
+ // <op_attribute> ::= "oneway"
+ // <op_type_spec> ::= <param_type_spec>
+ // | "void"
+ // <parameter_dcls> ::= "(" <param_dcl> {"," <param_dcl>}* ")"
+ // | "(" ")"
+ // <raises_expr> ::= "raises" "(" <scoped_name> {"," <scoped_name>}* ")"
+ // <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"
+
+
+ Operation operation = generateOperation(node.toString());
+
+ BindingOperation bindingOperation = generateBindingOperation(binding, operation);
+
+ XmlSchemaSequence inputWrappingSequence = new XmlSchemaSequence();
+ XmlSchemaElement inputElement = generateWrapper(new QName(schema.getTargetNamespace(),
+ operation.getName()),
+ inputWrappingSequence);
+ inputMsg = generateInputMessage(operation, bindingOperation);
+ inputPart = generateInputPart(inputMsg, inputElement);
+
+ // <op_attribute>
+ node = node.getFirstChild();
+ XmlSchemaSequence outputWrappingSequence = null;
+ XmlSchemaElement outputElement = null;
+ if (node != null && (node.getType() == IDLTokenTypes.LITERAL_oneway)) {
+ // oneway operations map to operations with only input message
+ // no outputMsg nor outputPart need be created
+ node = node.getNextSibling();
} else {
// normal operations map to request-response operations
// with input and output messages
- msgVisitor.createInputMessage();
- msgVisitor.createOutputMessage();
+ outputWrappingSequence = new XmlSchemaSequence();
+ outputElement = generateWrapper(new QName(schema.getTargetNamespace(),
+ operation.getName() + RESPONSE_SUFFIX),
+ outputWrappingSequence);
+ outputMsg = generateOutputMessage(operation, bindingOperation);
+ outputPart = generateOutputPart(outputMsg, outputElement);
+ }
+
+ // <op_type_spec>
+ visitOpTypeSpec(node, outputWrappingSequence);
+
+ // <parameter_dcls>
+ node = node.getNextSibling();
+ while (ParamDclVisitor.accept(node)) {
+ ParamDclVisitor visitor = new ParamDclVisitor(getScope(),
+ schemas,
+ schema,
+ typeMap,
+ inputWrappingSequence,
+ outputWrappingSequence,
+ corbaOperation);
+ visitor.visit(node);
+
+ node = node.getNextSibling();
+ }
+
+ // <raises_expr>
+ if (node != null
+ && node.getType() == IDLTokenTypes.LITERAL_raises) {
+ node = node.getFirstChild();
+
+ while (node != null) {
+// ScopedNameVisitor visitor = new ScopedNameVisitor(schemas,
+// schema,
+// typeMap);
+// visitor.visit(node);
+// XmlSchemaType schemaType = visitor.getSchemaType();
+// CorbaTypeImpl corbaType = visitor.getCorbaType();
+
+ createFaultMessage(node, operation, bindingOperation);
+
+ node = node.getNextSibling();
+ }
}
- msgVisitor.visit(node);
+
}
- private BindingOperation createBindingOperation(Binding wsdlBinding, Operation op) {
+ private Operation generateOperation(String name) {
+ Operation op = definition.createOperation();
+ op.setName(name);
+ op.setUndefined(false);
+ portType.addOperation(op);
+ return op;
+ }
+
+ private BindingOperation generateBindingOperation(Binding wsdlBinding, Operation op) {
BindingOperation bindingOperation = definition.createBindingOperation();
- OperationType operationType = null;
+ //OperationType operationType = null;
try {
- operationType = (OperationType)extReg.createExtension(BindingOperation.class,
- CorbaConstants.NE_CORBA_OPERATION);
+ corbaOperation = (OperationType)extReg.createExtension(BindingOperation.class,
+ CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException ex) {
throw new RuntimeException(ex);
}
- operationType.setName(op.getName());
- bindingOperation.addExtensibilityElement(operationType);
+ corbaOperation.setName(op.getName());
+ bindingOperation.addExtensibilityElement(corbaOperation);
bindingOperation.setOperation(op);
bindingOperation.setName(op.getName());
binding.addBindingOperation(bindingOperation);
return bindingOperation;
}
+
+ public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
+ Message msg = definition.createMessage();
+ msg.setQName(new QName(definition.getTargetNamespace(), operation.getName()));
+ msg.setUndefined(false);
+
+ String inputName = operation.getName() + REQUEST_SUFFIX;
+ Input input = definition.createInput();
+ input.setName(inputName);
+ input.setMessage(msg);
+
+ BindingInput bindingInput = definition.createBindingInput();
+ bindingInput.setName(inputName);
+
+ bindingOperation.setBindingInput(bindingInput);
+ operation.setInput(input);
+
+ definition.addMessage(msg);
+
+ return msg;
+ }
+
+ public Message generateOutputMessage(Operation operation, BindingOperation bindingOperation) {
+ Message msg = definition.createMessage();
+ msg.setQName(new QName(definition.getTargetNamespace(),
+ operation.getName() + RESPONSE_SUFFIX));
+ msg.setUndefined(false);
+
+ String outputName = operation.getName() + RESPONSE_SUFFIX;
+ Output output = definition.createOutput();
+ output.setName(outputName);
+ output.setMessage(msg);
+
+ BindingOutput bindingOutput = definition.createBindingOutput();
+ bindingOutput.setName(outputName);
+
+ bindingOperation.setBindingOutput(bindingOutput);
+ operation.setOutput(output);
+
+ definition.addMessage(msg);
+
+ return msg;
+ }
+
+ private Part generateInputPart(Message inputMessage, XmlSchemaElement element) {
+ // message - part
+ Part part = definition.createPart();
+ part.setName(IN_PARAMETER);
+ part.setElementName(element.getQName());
+ inputMessage.addPart(part);
+ return part;
+ }
+
+ private Part generateOutputPart(Message outputMessage, XmlSchemaElement element) {
+ // message - part
+ Part part = definition.createPart();
+ part.setName(OUT_PARAMETER);
+ part.setElementName(element.getQName());
+ outputMessage.addPart(part);
+ return part;
+ }
+
+ /*-
+ * Build the Wrapped Document Style wrapping elements
+ * i.e. <xs:element name="...">
+ * <xs:complexType>
+ * <xs:sequence>
+ * ...
+ * </xs:sequence>
+ * </xs:complexType>
+ * </xs:element>
+ */
+ private XmlSchemaElement generateWrapper(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);
+
+ return wrappingSchemaElement;
+ }
+
+ private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence,
+ XmlSchemaType schemaType,
+ String name) {
+ XmlSchemaElement element = new XmlSchemaElement();
+ element.setName(name);
+ element.setSchemaTypeName(schemaType.getQName());
+
+ schemaSequence.getItems().add(element);
+
+ return element;
+ }
+
+ private void visitOpTypeSpec(AST node, XmlSchemaSequence outputWrappingSequence) {
+ if (node.getType() == IDLTokenTypes.LITERAL_void) {
+ // nothing to do here, move along
+ return;
+ } else {
+ ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), schemas, schema, typeMap);
+ visitor.visit(node);
+
+ XmlSchemaType schemaType = visitor.getSchemaType();
+ CorbaTypeImpl corbaType = visitor.getCorbaType();
+
+ addElement(outputWrappingSequence, schemaType, RETURN_PARAMETER);
+ addCorbaReturn(corbaType, RETURN_PARAMETER);
+ }
+ }
+
+ private void addCorbaReturn(CorbaTypeImpl corbaType, String partName) {
+ ArgType param = new ArgType();
+ param.setName(partName);
+ param.setIdltype(corbaType.getQName());
+ corbaOperation.setReturn(param);
+ }
+
+ private void createFaultMessage(AST node,
+ Operation operation,
+ BindingOperation bindingOperation) {
+ String exceptionName = node.toString();
+
+ // message
+ Message faultMsg = definition.createMessage();
+ faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));
+ faultMsg.setUndefined(false);
+
+ // message - part
+ Part part = definition.createPart();
+ part.setName("exception");
+ // REVISIT: should be reading QName from exception XmlSchemaElement
+ // part.setElementName(element.getQName());
+ part.setElementName(new QName(definition.getTargetNamespace(), exceptionName));
+ faultMsg.addPart(part);
+
+ // porttype - operation - fault
+ Fault fault = definition.createFault();
+ fault.setMessage(faultMsg);
+ fault.setName(faultMsg.getQName().getLocalPart());
+ operation.addFault(fault);
+
+ // binding - operation - corba:operation - corba:raises
+ RaisesType raisesType = new RaisesType();
+ raisesType.setException(new QName(typeMap.getTargetNamespace(),
+ exceptionName));
+ corbaOperation.getRaises().add(raisesType);
+
+ // binding - operation - fault
+ BindingFault bindingFault = definition.createBindingFault();
+ bindingFault.setName(faultMsg.getQName().getLocalPart());
+ bindingOperation.addBindingFault(bindingFault);
+
+ definition.addMessage(faultMsg);
+ }
}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java (from r480008, incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java)
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java?view=diff&rev=480098&p1=incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java&r1=480008&p2=incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java&r2=480098
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java Tue Nov 28 07:42:24 2006
@@ -47,7 +47,7 @@
if (PrimitiveTypesVisitor.accept(node)) {
// base_type_spec
- visitor = new PrimitiveTypesVisitor(getScope());
+ visitor = new PrimitiveTypesVisitor(getScope(), schemas);
} else if (StringVisitor.accept(node)) {
// string_type_spec
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java Tue Nov 28 07:42:24 2006
@@ -30,73 +30,115 @@
import javax.xml.namespace.QName;
-import antlr.ASTVisitor;
import antlr.collections.AST;
import org.apache.schemas.yoko.bindings.corba.BindingType;
+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.yoko.wsdl.CorbaConstants;
-public class PortTypeVisitor implements ASTVisitor {
+public class PortTypeVisitor extends VisitorBase {
Definition definition;
ExtensionRegistry extReg;
PortType portType;
WSDLASTVisitor wsdlASTVisitor;
- TypesVisitor typesVisitor;
String module;
- public PortTypeVisitor(WSDLASTVisitor visitor) {
- definition = visitor.getDefinition();
- wsdlASTVisitor = visitor;
- typesVisitor = wsdlASTVisitor.getTypesVisitor();
+ public PortTypeVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType corbaTypeMap,
+ Definition wsdlDefinition) {
+ super(scope, xmlSchemas, xmlSchema, corbaTypeMap);
+ definition = wsdlDefinition;
extReg = definition.getExtensionRegistry();
}
- public void addModuleName(String name) {
- if (module != null) {
- module += "." + name;
- } else {
- module = name;
+ public static boolean accept(AST node) {
+ if (node.getType() == IDLTokenTypes.LITERAL_interface) {
+ return true;
}
+ return false;
}
-
+
public void visit(AST node) {
+ // <interface> ::= <interface_dcl>
+ // | <forward_dcl>
+ // <interface_dcl> ::= <interface_header> "{" <interface_body> "}"
+ // <forward_dcl> ::= ["abstract" | "local"] "interface" <identifier>
+ // <interface_header> ::= ["abstract" | "local"] "interface" <identifier>
+ // [<interface_inheritance_spec>]
+ // <interface_body> ::= <export>*
+ // <export> ::= <type_dcl> ";"
+ // | <const_dcl> ";"
+ // | <except_dcl> ";"
+ // | <attr_dcl> ";"
+ // | <op_dcl> ";"
+ // <interface_inheritance_spec> ::= ":" <interface_name> { "," <interface_name> }*
+ // <interface_name> ::= <scoped_name>
+
+
+ AST identifierNode = node.getFirstChild();
+ String interfaceName = identifierNode.toString();
+
+ Scope interfaceScope = new Scope(getScope(), interfaceName);
+ //Scope interfaceScope = getScope();
+
portType = definition.createPortType();
- AST interfaceNode = node.getFirstChild();
- String intfName = interfaceNode.toString();
- if (module != null) {
- intfName = module + "." + intfName;
- }
- portType.setQName(new QName(definition.getTargetNamespace(), intfName));
+ portType.setQName(new QName(definition.getTargetNamespace(), interfaceScope.toString()));
portType.setUndefined(false);
definition.addPortType(portType);
Binding binding = createBinding();
- AST node2 = interfaceNode.getNextSibling();
- while (node2 != null) {
- switch (node2.getType()) {
- case IDLTokenTypes.LITERAL_struct:
- case IDLTokenTypes.LITERAL_exception:
- case IDLTokenTypes.LITERAL_const:
- case IDLTokenTypes.LITERAL_enum:
- case IDLTokenTypes.LITERAL_union:
- case IDLTokenTypes.LITERAL_typedef:
- typesVisitor.visit(node2);
- break;
- case IDLTokenTypes.LITERAL_attribute:
- AttributeVisitor attributeVisitor = new AttributeVisitor(wsdlASTVisitor,
- portType,
- binding);
- attributeVisitor.visit(node2);
- break;
- default:
- OperationVisitor operationVisitor = new OperationVisitor(wsdlASTVisitor,
+
+ AST exportNode = identifierNode.getNextSibling();
+ while (exportNode != null) {
+
+ if (TypeDclVisitor.accept(exportNode)) {
+ TypeDclVisitor visitor = new TypeDclVisitor(interfaceScope,
+ schemas,
+ schema,
+ typeMap);
+ visitor.visit(exportNode);
+ } else if (ConstVisitor.accept(exportNode)) {
+ ConstVisitor visitor = new ConstVisitor(interfaceScope,
+ schemas,
+ schema,
+ typeMap);
+ visitor.visit(exportNode);
+ } else if (ExceptionVisitor.accept(exportNode)) {
+ ExceptionVisitor visitor = new ExceptionVisitor(interfaceScope,
+ schemas,
+ schema,
+ typeMap);
+ visitor.visit(exportNode);
+ } else if (AttributeVisitor.accept(exportNode)) {
+ AttributeVisitor attributeVisitor = new AttributeVisitor(interfaceScope,
+ schemas,
+ schema,
+ typeMap,
+ definition,
portType,
binding);
- operationVisitor.visit(node2);
- break;
+ attributeVisitor.visit(exportNode);
+ } else if (OperationVisitor.accept(interfaceScope, schemas, schema, typeMap, exportNode)) {
+ OperationVisitor visitor = new OperationVisitor(interfaceScope,
+ schemas,
+ schema,
+ typeMap,
+ definition,
+ portType,
+ binding);
+ visitor.visit(exportNode);
+ } else {
+ throw new RuntimeException("[InterfaceVisitor] Invalid IDL: unknown element "
+ + exportNode.toString());
}
- node2 = node2.getNextSibling();
+
+ exportNode = exportNode.getNextSibling();
}
}
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java Tue Nov 28 07:42:24 2006
@@ -19,27 +19,194 @@
package org.apache.yoko.tools.processors.idl;
-import antlr.collections.AST;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
-import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import antlr.collections.AST;
-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.tools.common.CorbaPrimitiveMap;
+import org.apache.yoko.tools.common.XmlSchemaPrimitiveMap;
+import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
-public class PrimitiveTypesVisitor extends TypesVisitorBase {
+public class PrimitiveTypesVisitor implements Visitor {
+
+ private static CorbaPrimitiveMap corbaPrimitiveMap = new CorbaPrimitiveMap();
+ private static XmlSchemaPrimitiveMap xmlSchemaPrimitiveMap = new XmlSchemaPrimitiveMap();
- public PrimitiveTypesVisitor(XmlSchemaCollection xmlSchemas,
- XmlSchema xmlSchema,
- TypeMappingType typeMapRef) {
- super(xmlSchemas, xmlSchema, typeMapRef);
+ 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_any));
}
+ private XmlSchemaType schemaType;
+ private CorbaTypeImpl corbaType;
+ private Scope scope;
+ private XmlSchemaCollection schemas;
+
+ public PrimitiveTypesVisitor(Scope scopeRef, XmlSchemaCollection xmlSchemas) {
+ scope = scopeRef;
+ schemas = xmlSchemas;
+ }
+
+ 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> ::= <floating_pt_type>
+ // | <integer_type>
+ // | <char_type>
+ // | <wide_char_type>
+ // | <boolean_type>
+ // | <octet_type>
+ // | <any_type>
+ // | <object_type> <= NOT SUPPORTED
+ // | <value_base_type> <= NOT SUPPORTED
+ // <floating_pt_type> ::= "float"
+ // | "double"
+ // | "long" double"
+ // <integer_type> ::= <signed_int>
+ // | <unsigned_int>
+ // <signed_int> ::= <signed_short_int>
+ // | <signed_long_int>
+ // | <signed_longlong_int>
+ // <signed_short_int> ::= "short"
+ // <signed_long_int> ::= "long"
+ // <signed_longlong_int> ::= "long" "long"
+ // <unsigned_int> ::= <unsigned_short_int>
+ // | <unsigned_long_int>
+ // | <unsigned_longlong_int>
+ // <unsigned_short_int> ::= "unsigned" "short"
+ // <unsigned_long_int> ::= "unsigned" "long"
+ // <unsigned_longlong_int> ::= "unsigned" "long" "long"
+ // <char_type> ::= "char"
+ // <wide_char_type> ::= "wchar"
+ // <boolean_type> ::= "boolean"
+ // <octet_type> ::= "octet"
+ // <any_type> ::= "any"
+
+
+ XmlSchemaType stype = null;
+ CorbaTypeImpl ctype = null;
+ QName corbaTypeQName = PrimitiveTypesVisitor.getPrimitiveType(node);
+ if (corbaTypeQName != null) {
+ QName schemaTypeQName = xmlSchemaPrimitiveMap.get(corbaTypeQName);
+ if (schemaTypeQName != null) {
+ //XmlSchemaCollection schemas = new XmlSchemaCollection();
+ stype = schemas.getTypeByQName(schemaTypeQName);
+ if (stype != null) {
+ ctype = new CorbaTypeImpl();
+ ctype.setQName(corbaTypeQName);
+ ctype.setType(stype.getQName());
+ ctype.setName(stype.getQName().getLocalPart());
+ }
+ }
}
+
+
+ schemaType = stype;
+ corbaType = ctype;
}
+
+ public XmlSchemaType getSchemaType() {
+ return schemaType;
+ }
+
+ public CorbaTypeImpl getCorbaType() {
+ return corbaType;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public 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
+ }
+ 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;
+ }
+ return result;
+ }
+
}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (from r480008, 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/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java?view=diff&rev=480098&p1=incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java&r1=480008&p2=incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java&r2=480098
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java Tue Nov 28 07:42:24 2006
@@ -70,7 +70,7 @@
if (PrimitiveTypesVisitor.accept(node)) {
// primitive type
- PrimitiveTypesVisitor primitiveVisitor = new PrimitiveTypesVisitor(null);
+ PrimitiveTypesVisitor primitiveVisitor = new PrimitiveTypesVisitor(null, schemas);
primitiveVisitor.visit(node);
stype = primitiveVisitor.getSchemaType();
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java (from r480008, 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/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java?view=diff&rev=480098&p1=incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java&r1=480008&p2=incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java&r2=480098
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java Tue Nov 28 07:42:24 2006
@@ -57,7 +57,7 @@
if (PrimitiveTypesVisitor.accept(node)) {
// simple_type_spec - base_type_spec
- visitor = new PrimitiveTypesVisitor(getScope());
+ visitor = new PrimitiveTypesVisitor(getScope(), schemas);
} else if (TemplateTypeSpecVisitor.accept(node)) {
// simple_type_spec - template_type_spec
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java?view=diff&rev=480098&r1=480097&r2=480098
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java Tue Nov 28 07:42:24 2006
@@ -39,55 +39,122 @@
import org.apache.yoko.wsdl.CorbaConstants;
import org.apache.yoko.wsdl.CorbaTypeImpl;
-public class StringVisitor extends TypesVisitorBase {
+public class StringVisitor extends VisitorBase {
private AST stringNode;
private AST boundNode;
- private AST typeNameNode;
- private String stringName;
+ private AST identifierNode;
+ private Scope stringScopedName;
+
- public StringVisitor(XmlSchemaCollection xmlSchemas,
+ public StringVisitor(Scope scope,
+ XmlSchemaCollection xmlSchemas,
XmlSchema xmlSchema,
- TypeMappingType typeMappingType) {
- super(xmlSchemas, xmlSchema, typeMappingType);
+ TypeMappingType typeMappingType,
+ AST identifierNodeRef) {
+ super(scope, xmlSchemas, xmlSchema, typeMappingType);
stringNode = null;
boundNode = null;
- typeNameNode = null;
- stringName = null;
+ identifierNode = identifierNodeRef;
+ stringScopedName = null;
+ }
+
+ 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 typedefNode) {
- stringNode = typedefNode.getFirstChild();
+ public static boolean isBounded(AST node) {
+ if (node.getFirstChild() == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public void visit(AST node) {
+ // <string_type> ::= "string" "<" <positive_int_const> ">"
+ // | "string"
+ // <wstring_type> ::= "wstring" "<" <positive_int_const> ">"
+ // | "wstring"
+
+
+ stringNode = node;
boundNode = stringNode.getFirstChild();
- typeNameNode = stringNode.getNextSibling();
- stringName = new String(typeNameNode.toString());
+
+ if (identifierNode == null) {
+ stringScopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
+ } else {
+ if (identifierNode.getFirstChild() == null) {
+ stringScopedName = new Scope(getScope(), identifierNode);
+ } else {
+ // array of anonymous bounded string
+ Scope anonScope = new Scope(getScope(), identifierNode);
+ stringScopedName = TypesUtils.generateAnonymousScopedName(anonScope, schema);
+ identifierNode = null;
+ }
+ }
if (boundNode != null) {
- // bounded string
- visitBoundedString();
+ if (identifierNode != null) {
+ // bounded string/wstring
+ visitBoundedString();
+ } else {
+ // anonymous bounded string/wstring
+ visitAnonBoundedString();
+ }
} else {
- // unbounded string
+ // unbounded string/wstring
visitUnboundedString();
}
}
+ private void visitAnonBoundedString() {
+ // xmlschema:bounded anon string
+ XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+ simpleType.setName(stringScopedName.toString());
+ XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+ restriction.setBaseTypeName(Constants.XSD_STRING);
+ XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
+ maxLengthFacet.setValue(boundNode.toString());
+ restriction.getFacets().add(maxLengthFacet);
+ simpleType.setContent(restriction);
+
+ // add schemaType
+ schema.getItems().add(simpleType);
+ schema.addType(simpleType);
+ setSchemaType(simpleType);
+
+ // corba:anonstring
+ Anonstring anonstring = new Anonstring();
+ anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
+ anonstring.setBound(new Long(boundNode.toString()));
+ anonstring.setType(simpleType.getQName());
+
+ // add corba:anonstring
+ typeMap.getStructOrExceptionOrUnion().add(anonstring);
+ setCorbaType(anonstring);
+ }
+
private void visitBoundedString() {
// xmlschema:bounded string
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
- simpleType.setName(stringName);
+ simpleType.setName(stringScopedName.toString());
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.setBaseTypeName(Constants.XSD_STRING);
XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet();
maxLengthFacet.setValue(boundNode.toString());
restriction.getFacets().add(maxLengthFacet);
simpleType.setContent(restriction);
-
- // add xmlschema:simpleType
- getSchema().getItems().add(simpleType);
- getSchema().addType(simpleType);
+
+ setSchemaType(simpleType);
- String anonstringName = new String("_1_" + stringName);
+ //String anonstringName = new String("_1_" + stringScopedName.toString());
+ Scope anonstringScopedName = new Scope(getScope(), "_1_" + stringScopedName.tail());
+ String anonstringName = anonstringScopedName.toString();
CorbaTypeImpl anon = null;
if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
// corba:anonstring
@@ -95,10 +162,7 @@
anonstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName));
anonstring.setBound(new Long(boundNode.toString()));
anonstring.setType(simpleType.getQName());
-
- // add corba:anonstring
- typeMap.getStructOrExceptionOrUnion().add(anonstring);
-
+
anon = anonstring;
} else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
@@ -108,9 +172,6 @@
anonwstring.setBound(new Long(boundNode.toString()));
anonwstring.setType(simpleType.getQName());
- // add corba:anonwstring
- typeMap.getStructOrExceptionOrUnion().add(anonwstring);
-
anon = anonwstring;
} else {
@@ -118,54 +179,53 @@
throw new RuntimeException("StringVisitor attempted to visit an invalid node");
}
+ // add corba:anonstring
+ typeMap.getStructOrExceptionOrUnion().add(anon);
+
// corba:alias
Alias alias = new Alias();
- alias.setQName(new QName(typeMap.getTargetNamespace(), stringName));
+ alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
alias.setBasetype(anon.getQName());
alias.setType(simpleType.getQName());
alias.setRepositoryID(CorbaConstants.REPO_STRING
- + stringName
+ + stringScopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
-
- // add corba:alias
- typeMap.getStructOrExceptionOrUnion().add(alias);
+ // add corba: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);
-
+ // schema type
+ setSchemaType(schemas.getTypeByQName(Constants.XSD_STRING));
+
- // corba:alias
- Alias alias = new Alias();
- alias.setQName(new QName(typeMap.getTargetNamespace(), stringName));
+ // corba type
+ CorbaTypeImpl corbaString = new CorbaTypeImpl();
if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
- alias.setBasetype(CorbaConstants.NT_CORBA_STRING);
+ corbaString.setQName(CorbaConstants.NT_CORBA_STRING);
+ corbaString.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
} else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
- alias.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
+ corbaString.setQName(CorbaConstants.NT_CORBA_WSTRING);
+ corbaString.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
} 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.setType(Constants.XSD_STRING);
+ setCorbaType(corbaString);
+ }
+
+ private String getIdentifier(AST node) {
+ String result = null;
+ if (node != null) {
+ String identifierName = node.toString();
+ if (TypesUtils.isValidIdentifier(identifierName)) {
+ result = identifierName;
+ }
+ }
+ return result;
}
}