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/21 11:24:20 UTC
svn commit: r477628 [1/7] - in
/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src:
main/java/org/apache/yoko/tools/processors/idl/ test/resources/idl/
Author: mvescovi
Date: Tue Nov 21 03:24:10 2006
New Revision: 477628
URL: http://svn.apache.org/viewvc?view=rev&rev=477628
Log:
YOKO-67 Adding dotted scoping support for named types.
Modified:
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.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/ExceptionVisitor.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/OperationVisitor.java
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.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/SimpleTypeSpecVisitor.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/TypesUtils.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/test/resources/idl/Anonsequence.idl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Enum.idl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonarray.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonboundedsequence.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonsequence.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Anonstring.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Array.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Attributes.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Const.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Enum.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Exception.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Fixed.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Sequence.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Struct.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Typedef.wsdl
incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/expected_Union.wsdl
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java Tue Nov 21 03:24:10 2006
@@ -71,21 +71,10 @@
AST firstSizeNode = node.getFirstChild();
AST nextSizeNode = firstSizeNode.getNextSibling();
Types result = null;
- Long index = new Long(0);
-
- // find first available index
- if (identifierNode == null) {
- QName qname = null;
- do {
- index++;
- qname = new QName(schema.getTargetNamespace(),
- generateAnonymousName(index));
- } while (schema.getTypeByName(qname) != null);
- }
// process all anonarrays, skip first array as it might not be anonymous
if (nextSizeNode != null) {
- result = doAnonarray(nextSizeNode, index, schemaType.getQName(), corbaType.getQName());
+ result = doAnonarray(nextSizeNode, schemaType.getQName(), corbaType.getQName());
} else {
result = new Types();
result.setSchemaType(schemaType);
@@ -97,14 +86,14 @@
XmlSchemaType stype = null;
CorbaTypeImpl ctype = null;
if (identifierNode != null) {
- String name = identifierNode.toString();
- stype = generateSchemaArray(name, size, result.getSchemaType().getQName());
- ctype = generateCorbaArray(name, size, result.getCorbaType().getQName());
+ Scope scopedName = getScope();
+ stype = generateSchemaArray(scopedName.toString(), size, result.getSchemaType().getQName());
+ ctype = generateCorbaArray(scopedName, size, result.getCorbaType().getQName());
} else {
// anonymous array
- String name = generateAnonymousName(index);
- stype = generateSchemaArray(name, size, result.getSchemaType().getQName());
- ctype = generateCorbaAnonarray(name, size, result.getCorbaType().getQName());
+ Scope scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
+ stype = generateSchemaArray(scopedName.toString(), size, result.getSchemaType().getQName());
+ ctype = generateCorbaAnonarray(scopedName.toString(), size, result.getCorbaType().getQName());
}
// add schemaType
@@ -118,30 +107,27 @@
setCorbaType(ctype);
}
- private Types doAnonarray(AST node, Long index, QName stype, QName ctype) {
+ private Types doAnonarray(AST node, QName stype, QName ctype) {
Types result = new Types();
if (node != null) {
AST next = node.getNextSibling();
- index++;
-
- // recursive call
- result = doAnonarray(next, index, stype, ctype);
-
+ result = doAnonarray(next, stype, ctype);
+
+ Scope scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
Long size = new Long(node.toString());
- String name = generateAnonymousName(index);
if (result.getSchemaType() == null) {
- result.setSchemaType(generateSchemaArray(name, size, stype));
+ result.setSchemaType(generateSchemaArray(scopedName.toString(), size, stype));
} else {
- result.setSchemaType(generateSchemaArray(name, size, result.getSchemaType().getQName()));
+ result.setSchemaType(generateSchemaArray(scopedName.toString(), size, result.getSchemaType().getQName()));
}
if (result.getCorbaType() == null) {
- result.setCorbaType(generateCorbaAnonarray(name, size, ctype));
+ result.setCorbaType(generateCorbaAnonarray(scopedName.toString(), size, ctype));
} else {
- result.setCorbaType(generateCorbaAnonarray(name, size, result.getCorbaType().getQName()));
+ result.setCorbaType(generateCorbaAnonarray(scopedName.toString(), size, result.getCorbaType().getQName()));
}
@@ -175,12 +161,12 @@
return complexType;
}
- private Array generateCorbaArray(String name, Long size, QName type) {
+ private Array generateCorbaArray(Scope scopedName, Long size, QName type) {
Array array = new Array();
- array.setQName(new QName(typeMap.getTargetNamespace(), name));
+ array.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
array.setBound(size);
array.setRepositoryID(CorbaConstants.REPO_STRING
- + name
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
array.setType(type);
return array;
@@ -192,15 +178,6 @@
anonarray.setBound(size);
anonarray.setType(type);
return anonarray;
- }
-
- private String generateAnonymousName(Long index) {
- StringBuffer name = new StringBuffer();
- name.append("_");
- name.append(index.toString());
- name.append("_");
- name.append(getScope().tail());
- return name.toString();
}
class Types {
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ConstVisitor.java Tue Nov 21 03:24:10 2006
@@ -75,7 +75,7 @@
}
QName constQName = new QName(typeMap.getTargetNamespace(),
- constNameNode.toString());
+ new Scope(getScope(), constNameNode).toString());
// TEMPORARILY
// using TypesVisitor to visit <const_type>
@@ -91,7 +91,6 @@
corbaConst.setQName(constQName);
corbaConst.setValue(constValue);
corbaConst.setType(constSchemaType.getQName());
- //corbaConst.setIdltype(constCorbaType.getQName());
corbaConst.setIdltype(constCorbaTypeName);
typeMap.getStructOrExceptionOrUnion().add(corbaConst);
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -61,10 +61,11 @@
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);
@@ -75,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());
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java Tue Nov 21 03:24:10 2006
@@ -72,10 +72,11 @@
AST identifierNode = node.getFirstChild();
- Scope newScope = new Scope(getScope(), identifierNode);
+ Scope exceptionScope = new Scope(getScope(), identifierNode);
// xmlschema:exception
- String exceptionName = identifierNode.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));
@@ -95,7 +96,7 @@
exception.setQName(new QName(typeMap.getTargetNamespace(), exceptionName));
exception.setType(complexType.getQName());
exception.setRepositoryID(CorbaConstants.REPO_STRING
- + exceptionName
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
@@ -104,7 +105,7 @@
while (memberTypeNode != null) {
AST memberNode = memberTypeNode.getNextSibling();
- TypesVisitor visitor = new TypesVisitor(newScope,
+ TypesVisitor visitor = new TypesVisitor(exceptionScope,
schemas,
schema,
typeMap,
@@ -115,7 +116,8 @@
// needed for anonymous arrays in exceptions
if (ArrayVisitor.accept(memberNode)) {
- ArrayVisitor arrayVisitor = new ArrayVisitor(newScope,
+ Scope anonScope = new Scope(exceptionScope, TypesUtils.getPrimitiveCorbaTypeNameNode(memberTypeNode));
+ ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,//exceptionScope,
schemas,
schema,
typeMap,
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -81,10 +81,9 @@
// <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());
@@ -111,7 +110,7 @@
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
@@ -120,11 +119,11 @@
// 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());
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java Tue Nov 21 03:24:10 2006
@@ -90,7 +90,7 @@
binding = wsdlBinding;
}
- public static boolean accept(XmlSchemaCollection schemas, XmlSchema schema,
+ public static boolean accept(Scope scope, XmlSchemaCollection schemas, XmlSchema schema,
TypeMappingType typeMap, AST node) {
boolean result = false;
AST node2 = node.getFirstChild();
@@ -102,7 +102,7 @@
type == IDLTokenTypes.LITERAL_void
|| PrimitiveTypesVisitor.accept(node2)
|| StringVisitor.accept(node2)
- || ScopedNameVisitor.accept(schemas, schema, typeMap, node2);
+ || ScopedNameVisitor.accept(scope, schemas, schema, typeMap, node2);
}
return result;
}
Modified: 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/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java Tue Nov 21 03:24:10 2006
@@ -54,10 +54,13 @@
// wstring_type_spec
visitor = new StringVisitor(getScope(), schemas, schema, typeMap, null);
- } else if (ScopedNameVisitor.accept(schemas, schema, typeMap, node)) {
+ } else if (ScopedNameVisitor.accept(getScope(), schemas, schema, typeMap, node)) {
// scoped_name
visitor = new ScopedNameVisitor(getScope(), schemas, schema, typeMap);
+ } else {
+ System.out.println("[ParamTypeSpecVisitor] Invalid IDL: unknown element " + node.toString());
+ System.exit(1);
}
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java Tue Nov 21 03:24:10 2006
@@ -58,14 +58,6 @@
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;
@@ -97,6 +89,7 @@
}
Scope interfaceScope = new Scope(getScope(), interfaceName);
+ //Scope interfaceScope = getScope();
portType = definition.createPortType();
portType.setQName(new QName(definition.getTargetNamespace(), interfaceName));
@@ -134,7 +127,7 @@
portType,
binding);
attributeVisitor.visit(exportNode);
- } else if (OperationVisitor.accept(schemas, schema, typeMap, exportNode)) {
+ } else if (OperationVisitor.accept(interfaceScope, schemas, schema, typeMap, exportNode)) {
OperationVisitor visitor = new OperationVisitor(interfaceScope,
schemas,
schema,
@@ -144,7 +137,8 @@
binding);
visitor.visit(exportNode);
} else {
- throw new RuntimeException("InterfaceVisitor: invalid IDL!");
+ throw new RuntimeException("[InterfaceVisitor] Invalid IDL: unknown element "
+ + exportNode.toString());
}
exportNode = exportNode.getNextSibling();
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java Tue Nov 21 03:24:10 2006
@@ -29,18 +29,22 @@
private static final String SEPARATOR = ".";
private List<String> scope;
+ private Scope parent;
public Scope() {
scope = new ArrayList<String>();
+ parent = this;
}
public Scope(Scope containingScope) {
scope = new ArrayList<String>(containingScope.scope);
+ parent = containingScope;
}
public Scope(Scope containingScope, String str) {
scope = new ArrayList<String>(containingScope.scope);
scope.add(str);
+ parent = containingScope;
}
public Scope(Scope containingScope, AST node) {
@@ -48,6 +52,7 @@
if (node != null) {
scope.add(node.toString());
}
+ parent = containingScope;
}
public String tail() {
@@ -59,16 +64,28 @@
}
}
- public String toString() {
+ public Scope getParent() {
+ return parent;
+ }
+
+ private String toString(String separator) {
StringBuffer result = new StringBuffer();
Iterator<String> it = scope.iterator();
while (it.hasNext()) {
result.append(it.next());
if (it.hasNext()) {
- result.append(SEPARATOR);
+ result.append(separator);
}
}
return result.toString();
+ }
+
+ public String toString() {
+ return toString(SEPARATOR);
+ }
+
+ public String toIDLRepositoryID() {
+ return toString("/");
}
}
Modified: 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=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java Tue Nov 21 03:24:10 2006
@@ -45,15 +45,15 @@
super(scope, xmlSchemas, xmlSchema, corbaTypeMap);
}
- public static boolean accept(XmlSchemaCollection schemas,
+ public static boolean accept(Scope scope,
+ XmlSchemaCollection schemas,
XmlSchema schema,
- TypeMappingType typeMap,
-// Scope scope,
+ TypeMappingType typeMap,
AST node) {
boolean result = false;
if (PrimitiveTypesVisitor.accept(node)) {
result = true;
- } else if (findSchemaType(schemas, schema, typeMap, node) != null) {
+ } else if (findSchemaType(scope, schemas, schema, typeMap, node) != null) {
result = true;
}
return result;
@@ -77,12 +77,27 @@
ctype = primitiveVisitor.getCorbaType();
} else {
// declared type
-// Scope scopedName = new Scope(scope, node);
-// QName schemaQName = new QName(schema.getTargetNamespace(), scopedName.toString());
- QName schemaQName = new QName(schema.getTargetNamespace(), node.toString());
-
- stype = schema.getTypeByName(schemaQName);
-
+ Scope currentScope = getScope();
+ while (stype == null
+ && currentScope != currentScope.getParent()) {
+ // A name can be used in an unqualified form within a particular scope;
+ // it will be resolved by successvely searching farther out in enclosing
+ // scopes, while taking into consideration inheritance relationships
+ // among interfaces.
+ // INHERITANCE NOT IMPLEMENTED YET
+ Scope scopedName = new Scope(currentScope, node);
+ QName schemaQName = new QName(schema.getTargetNamespace(), scopedName.toString());
+
+ stype = schema.getTypeByName(schemaQName);
+
+ currentScope = currentScope.getParent();
+ }
+ if (stype == null) {
+ // Global scope is our last chance to resolve the node
+ QName schemaQName = new QName(schema.getTargetNamespace(), node.toString());
+ stype = schema.getTypeByName(schemaQName);
+ }
+
// handle special case of simple string alias
// a plain xsd:string has no corresponding XmlSchemaType in the XmlSchema
// so the previous findType() method would return null.
@@ -90,8 +105,20 @@
// same name. If the string is there, then it had been previously properly
// declared and we can use it here.
if (stype == null) {
- QName corbaQName = new QName(typeMap.getTargetNamespace(), node.toString());
- ctype = findCorbaType(typeMap, corbaQName);
+ QName corbaQName = null;
+ currentScope = getScope();
+ while (ctype == null
+ && currentScope != currentScope.getParent()) {
+ Scope scopedName = new Scope(currentScope, node);
+ corbaQName = new QName(typeMap.getTargetNamespace(), scopedName.toString());
+ ctype = findCorbaType(typeMap, corbaQName);
+
+ currentScope = currentScope.getParent();
+ }
+ if (ctype == null) {
+ corbaQName = new QName(typeMap.getTargetNamespace(), node.toString());
+ ctype = findCorbaType(typeMap, corbaQName);
+ }
if (ctype != null && ctype.getType() == Constants.XSD_STRING) {
stype = schemas.getTypeByQName(Constants.XSD_STRING);
ctype = new CorbaTypeImpl();
@@ -113,18 +140,31 @@
}
- private static XmlSchemaType findSchemaType(XmlSchemaCollection schemas,
+ private static XmlSchemaType findSchemaType(Scope scope,
+ XmlSchemaCollection schemas,
XmlSchema schema,
TypeMappingType typeMap,
AST node) {
XmlSchemaType result = null;
+ Scope currentScope = scope;
+ while (result == null
+ && currentScope != currentScope.getParent()) {
+ // A name can be used in an unqualified form within a particular scope;
+ // it will be resolved by successvely searching farther out in enclosing
+ // scopes, while taking into consideration inheritance relationships
+ // among interfaces.
+ // INHERITANCE NOT IMPLEMENTED YET
+ Scope scopedName = new Scope(currentScope, node);
+ QName qname = new QName(schema.getTargetNamespace(), scopedName.toString());
+ result = schema.getTypeByName(qname);
+ currentScope = currentScope.getParent();
+ }
if (result == null) {
-// Scope scopedName = new Scope(scope, node);
-// QName qname = new QName(schema.getTargetNamespace(), scopedName.toString());
+ // Global scope is our last chance to resolve the node
QName qname = new QName(schema.getTargetNamespace(), node.toString());
result = schema.getTypeByName(qname);
}
-
+
// handle special case of simple string alias
// a plain xsd:string has no corresponding XmlSchemaType in the XmlSchema
// so the previous findType() method would return null.
@@ -132,8 +172,18 @@
// same name. If the string is there, then it had been previously properly
// declared and we can use it here.
if (result == null) {
- QName corbaStringQname = new QName(typeMap.getTargetNamespace(), node.toString());
- CorbaTypeImpl ctype = findCorbaType(typeMap, corbaStringQname);
+ CorbaTypeImpl ctype = null;
+ currentScope = scope;
+ while (ctype == null
+ && currentScope != currentScope.getParent()) {
+ QName corbaStringQname = new QName(typeMap.getTargetNamespace(), currentScope.toString());
+ ctype = findCorbaType(typeMap, corbaStringQname);
+ currentScope = currentScope.getParent();
+ }
+ if (ctype == null) {
+ QName corbaStringQname = new QName(typeMap.getTargetNamespace(), node.toString());
+ ctype = findCorbaType(typeMap, corbaStringQname);
+ }
if (ctype != null
&& ctype.getType() == Constants.XSD_STRING) {
result = schemas.getTypeByQName(Constants.XSD_STRING);
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -84,33 +84,26 @@
bound = Long.parseLong(boundNode.toString());
}
- String name = null;
- XmlSchemaType anonSchemaType = null;
+ Scope scopedName = null;
if (identifierNode == null) {
// anonymous type
- Integer id = 0;
- do {
- id++;
- name = "_" + id.toString() + "_" + getScope().tail();
- anonSchemaType = schema.getTypeByName(new QName(schema.getTargetNamespace(),
- name));
- } while (anonSchemaType != null);
+ scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
} else {
- name = identifierNode.toString();
+ scopedName = new Scope(getScope(), identifierNode);
}
-
- XmlSchemaType schemaType = generateSchemaType(stype, name, bound);
+
+ XmlSchemaType schemaType = generateSchemaType(stype, scopedName, bound);
CorbaTypeImpl corbaType = null;
if (identifierNode == null) {
corbaType = generateCorbaAnonsequence(ctype,
schemaType,
- name,
+ scopedName,
bound);
} else {
corbaType = generateCorbaSequence(ctype,
schemaType,
- name,
+ scopedName,
bound);
}
@@ -119,9 +112,9 @@
setCorbaType(corbaType);
}
- private XmlSchemaType generateSchemaType(XmlSchemaType stype, String name, long bound) {
+ private XmlSchemaType generateSchemaType(XmlSchemaType stype, Scope scopedName, long bound) {
XmlSchemaComplexType ct = new XmlSchemaComplexType(schema);
- ct.setName(name);
+ ct.setName(scopedName.toString());
XmlSchemaSequence sequence = new XmlSchemaSequence();
XmlSchemaElement el = new XmlSchemaElement();
el.setName("item");
@@ -139,7 +132,7 @@
private CorbaTypeImpl generateCorbaSequence(CorbaTypeImpl ctype,
XmlSchemaType schemaType,
- String name,
+ Scope scopedName,
long bound) {
//create the corba sequence
Sequence corbaSeq = new Sequence();
@@ -147,11 +140,11 @@
bound = 0;
}
corbaSeq.setBound(bound);
- corbaSeq.setQName(new QName(typeMap.getTargetNamespace(), name));
+ corbaSeq.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
corbaSeq.setType(schemaType.getQName());
corbaSeq.setElemtype(ctype.getQName());
corbaSeq.setRepositoryID(CorbaConstants.REPO_STRING
- + name
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
return corbaSeq;
@@ -159,7 +152,7 @@
private Anonsequence generateCorbaAnonsequence(CorbaTypeImpl ctype,
XmlSchemaType schemaType,
- String name,
+ Scope scopedName,
long bound) {
// create corba anonsequence
Anonsequence result = new Anonsequence();
@@ -167,7 +160,7 @@
bound = 0;
}
result.setBound(bound);
- result.setQName(new QName(typeMap.getTargetNamespace(), name));
+ result.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
result.setType(schemaType.getQName());
result.setElemtype(ctype.getQName());
@@ -180,5 +173,5 @@
return result;
}
-
+
}
Modified: 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=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/SimpleTypeSpecVisitor.java Tue Nov 21 03:24:10 2006
@@ -63,7 +63,7 @@
// simple_type_spec - template_type_spec
visitor = new TemplateTypeSpecVisitor(getScope(), schemas, schema, typeMap, identifierNode);
- } else if (ScopedNameVisitor.accept(schemas, schema, typeMap, node)) {
+ } else if (ScopedNameVisitor.accept(getScope(), schemas, schema, typeMap, node)) {
// simple_type_spec - scoped_name
visitor = new ScopedNameVisitor(getScope(), schemas, schema, typeMap);
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -44,7 +44,7 @@
private AST stringNode;
private AST boundNode;
private AST identifierNode;
- private String stringName;
+ private Scope stringScopedName;
public StringVisitor(Scope scope,
@@ -56,7 +56,7 @@
stringNode = null;
boundNode = null;
identifierNode = identifierNodeRef;
- stringName = null;
+ stringScopedName = null;
}
public static boolean accept(AST node) {
@@ -84,15 +84,10 @@
stringNode = node;
boundNode = stringNode.getFirstChild();
if (identifierNode == null) {
- Integer index = 0;
- do {
- index++;
- stringName = "_" + index.toString() + "_" + getScope().tail();
- } while (schema.getTypeByName(new QName(schema.getTargetNamespace(), stringName)) != null);
+ stringScopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
} else {
- stringName = getIdentifier(identifierNode);
+ stringScopedName = new Scope(getScope(), identifierNode);
}
-
if (boundNode != null) {
if (identifierNode != null) {
@@ -111,7 +106,7 @@
private void visitAnonBoundedString() {
// xmlschema:bounded anon 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();
@@ -126,7 +121,7 @@
// corba:anonstring
Anonstring anonstring = new Anonstring();
- anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringName));
+ anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
anonstring.setBound(new Long(boundNode.toString()));
anonstring.setType(simpleType.getQName());
@@ -138,7 +133,7 @@
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();
@@ -149,7 +144,9 @@
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
@@ -179,11 +176,11 @@
// 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
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -57,24 +57,24 @@
// <struct_type> ::= "struct" <identifier> "{" <member_list> "}"
// <member_list> ::= <member>+
// <member> ::= <type_spec> <declarators> ";"
+
AST identifierNode = node.getFirstChild();
- Scope newScope = new Scope(getScope(), identifierNode);
+ Scope structScope = new Scope(getScope(), identifierNode);
+
// xmlschema:struct
- String structName = identifierNode.toString();
- //String structName = newScope.toString();
XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema);
- complexType.setName(structName);
+ complexType.setName(structScope.toString());
XmlSchemaSequence sequence = new XmlSchemaSequence();
complexType.setParticle(sequence);
// corba:struct
Struct struct = new Struct();
- struct.setQName(new QName(typeMap.getTargetNamespace(), structName));
+ struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
struct.setType(complexType.getQName());
struct.setRepositoryID(CorbaConstants.REPO_STRING
- + structName
+ + structScope.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
@@ -86,7 +86,7 @@
XmlSchemaType schemaType = null;
CorbaTypeImpl corbaType = null;
try {
- TypesVisitor visitor = new TypesVisitor(newScope,
+ TypesVisitor visitor = new TypesVisitor(structScope,
schemas,
schema,
typeMap,
@@ -103,7 +103,8 @@
// needed for anonymous arrays in structs
if (ArrayVisitor.accept(memberNode)) {
- ArrayVisitor arrayVisitor = new ArrayVisitor(newScope,
+ Scope anonScope = new Scope(structScope, TypesUtils.getPrimitiveCorbaTypeNameNode(memberTypeNode));
+ ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
schemas,
schema,
typeMap,
@@ -137,7 +138,7 @@
// declaration phase
XmlSchemaType schemaType = complexType;
CorbaTypeImpl corbaType = struct;
- DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(newScope,
+ DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(structScope,
schemas,
schema,
typeMap,
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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -65,13 +65,13 @@
XmlSchemaType schemaType = typesVisitor.getSchemaType();
CorbaTypeImpl corbaType = typesVisitor.getCorbaType();
- Scope newScope = new Scope(getScope(), identifierNode);
+ Scope typedefScope = new Scope(getScope(), identifierNode);
if (SequenceVisitor.accept(typeDeclaratorNode)
|| FixedVisitor.accept(typeDeclaratorNode)) {
// Handle cases "typedef sequence"
// "typedef fixed"
- DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(newScope,
+ DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
schemas,
schema,
typeMap,
@@ -84,7 +84,7 @@
// "typedef wstring"
if (StringVisitor.isBounded(typeDeclaratorNode)) {
- DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(newScope,
+ DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
schemas,
schema,
typeMap,
@@ -100,12 +100,13 @@
corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
} else {
// should never get here
- throw new RuntimeException("StringVisitor attempted to visit an invalid node");
+ throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid node: "
+ + typeDeclaratorNode.toString());
}
- corbaString.setQName(new QName(typeMap.getTargetNamespace(), identifierNode.toString()));
+ corbaString.setQName(new QName(typeMap.getTargetNamespace(), typedefScope.toString()));
corbaString.setType(Constants.XSD_STRING);
corbaString.setRepositoryID(CorbaConstants.REPO_STRING
- + identifierNode.toString()
+ + typedefScope.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
typeMap.getStructOrExceptionOrUnion().add(corbaString);
@@ -125,7 +126,7 @@
corbaType = getCorbaType();
}
- DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(newScope,
+ DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope,
schemas,
schema,
typeMap,
@@ -145,7 +146,8 @@
CorbaTypeImpl corbaType) {
// xmlschema:simpleType
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
- simpleType.setName(identifierNode.toString());
+ Scope scopedName = new Scope(getScope(), identifierNode);
+ simpleType.setName(scopedName.toString());
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.setBaseTypeName(schemaType.getQName());
simpleType.setContent(restriction);
@@ -156,11 +158,11 @@
// corba:alias
Alias alias = new Alias();
- alias.setQName(new QName(typeMap.getTargetNamespace(), identifierNode.toString()));
+ alias.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
alias.setBasetype(corbaType.getQName());
alias.setType(schemaType.getQName());
alias.setRepositoryID(CorbaConstants.REPO_STRING
- + identifierNode.toString()
+ + scopedName.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
// add corba:alias
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesUtils.java Tue Nov 21 03:24:10 2006
@@ -19,6 +19,11 @@
package org.apache.yoko.tools.processors.idl;
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
import antlr.collections.AST;
public final class TypesUtils {
@@ -72,4 +77,23 @@
return result;
}
+ public static Scope generateAnonymousScopedName(Scope scope, XmlSchema schema) {
+ Scope scopedName = null;
+ XmlSchemaType anonSchemaType = null;
+ Integer id = 0;
+ do {
+ id++;
+ StringBuffer name = new StringBuffer();
+ name.append("_");
+ name.append(id.toString());
+ name.append("_");
+ name.append(scope.tail());
+ scopedName = new Scope(scope.getParent(), name.toString());
+ QName scopedQName = new QName(schema.getTargetNamespace(), scopedName.toString());
+ anonSchemaType = schema.getTypeByName(scopedQName);
+ } while (anonSchemaType != null);
+
+ return scopedName;
+ }
+
}
Modified: incubator/yoko/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=477628&r1=477627&r2=477628
==============================================================================
--- 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 Tue Nov 21 03:24:10 2006
@@ -73,14 +73,14 @@
AST identifierNode = unionNode.getFirstChild();
- Scope newScope = new Scope(getScope(), identifierNode);
+ Scope unionScope = new Scope(getScope(), identifierNode);
AST discriminatorNode = identifierNode.getNextSibling();
AST caseNode = discriminatorNode.getNextSibling();
// xmlschema:union
XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema);
XmlSchemaSequence sequence = new XmlSchemaSequence();
- unionSchemaComplexType.setName(identifierNode.toString());
+ unionSchemaComplexType.setName(unionScope.toString());
unionSchemaComplexType.setParticle(sequence);
// REVISIT
@@ -107,14 +107,14 @@
// corba:union
Union corbaUnion = new Union();
- corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), identifierNode.toString()));
+ corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
corbaUnion.setRepositoryID(CorbaConstants.REPO_STRING
- + identifierNode.toString()
+ + unionScope.toIDLRepositoryID()
+ CorbaConstants.IDL_VERSION);
corbaUnion.setType(unionSchemaComplexType.getQName());
corbaUnion.setDiscriminator(ctype.getQName());
- processCaseNodes(caseNode, newScope, choice, corbaUnion);
+ processCaseNodes(caseNode, unionScope, choice, corbaUnion);
XmlSchemaType schemaType = unionSchemaComplexType;
@@ -180,7 +180,8 @@
// needed for anonymous arrays in unions
if (ArrayVisitor.accept(nameNode)) {
- ArrayVisitor arrayVisitor = new ArrayVisitor(scope,
+ Scope anonScope = new Scope(scope, TypesUtils.getPrimitiveCorbaTypeNameNode(nameNode));
+ ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,//scope,
schemas,
schema,
typeMap,
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonsequence.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonsequence.idl?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonsequence.idl (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Anonsequence.idl Tue Nov 21 03:24:10 2006
@@ -45,18 +45,18 @@
case 1:
sequence< long > unionSeqLong;
case 2:
- sequence< sequence< long > > unionSeqLong;
+ sequence< sequence< long > > unionSeqSeqLong;
default:
- sequence< sequence< sequence< long > > > unionSeqLong;
+ sequence< sequence< sequence< long > > > unionSeqSeqSeqLong;
};
typedef union anonTypedefUnion switch(long) {
case 1:
sequence< long > typedefUnionSeqLong;
case 2:
- sequence< sequence< long > > typedefUnionSeqLong;
+ sequence< sequence< long > > typedefUnionSeqSeqLong;
default:
- sequence< sequence< sequence< long > > > typedefUnionSeqLong;
+ sequence< sequence< sequence< long > > > typedefUnionSeqSeqSeqLong;
} myAnonUnion;
Modified: incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Enum.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Enum.idl?view=diff&rev=477628&r1=477627&r2=477628
==============================================================================
--- incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Enum.idl (original)
+++ incubator/yoko/branches/idltowsdl_anon_refactor/tools/src/test/resources/idl/Enum.idl Tue Nov 21 03:24:10 2006
@@ -33,13 +33,13 @@
void if2_op3(inout e_type1 inout_e_type1);
};
-/*
-module M
+module m1
{
enum e_type3 {e3_1, e3_2, e3_3};
- interface if2 {
- enum e_type4 {e4_1, e4_2, e4_3};
+ interface if3 {
+ enum e_type4 {e4_1, e4_2, e4_3};
+ void if3_op1(in e_type3 in_e_type3);
+ void if3_op2(in e_type4 in_e_type4);
};
};
-*/