You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2007/09/04 14:39:45 UTC
svn commit: r572651 [4/6] - in /webservices/axis2/trunk/java: ./
modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ modules/corba/
modules/corba/src/ modules/corba/src/org/ modules/corba/src/org/apache/
modules/corba/src/org/apache/axis2/ module...
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLTokenTypes.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLTokenTypes.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLTokenTypes.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLTokenTypes.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,121 @@
+// $ANTLR 2.7.6 (2005-12-22): "org.apache.axis2.corba.idl.g" -> "IDLParser.java"$
+
+ package org.apache.axis2.corba.idl.parser;
+
+public interface IDLTokenTypes {
+ int EOF = 1;
+ int NULL_TREE_LOOKAHEAD = 3;
+ int SEMI = 4;
+ int LITERAL_abstract = 5;
+ int LITERAL_local = 6;
+ int LITERAL_interface = 7;
+ int LITERAL_custom = 8;
+ int LITERAL_valuetype = 9;
+ int LITERAL_eventtype = 10;
+ int LITERAL_module = 11;
+ int LCURLY = 12;
+ int RCURLY = 13;
+ int PREPROC_DIRECTIVE = 14;
+ int COLON = 15;
+ int COMMA = 16;
+ int SCOPEOP = 17;
+ int IDENT = 18;
+ int LITERAL_truncatable = 19;
+ int LITERAL_supports = 20;
+ int LITERAL_public = 21;
+ int LITERAL_private = 22;
+ int LITERAL_factory = 23;
+ int LPAREN = 24;
+ int RPAREN = 25;
+ int LITERAL_in = 26;
+ int LITERAL_const = 27;
+ int ASSIGN = 28;
+ int OR = 29;
+ int XOR = 30;
+ int AND = 31;
+ int LSHIFT = 32;
+ int RSHIFT = 33;
+ int PLUS = 34;
+ int MINUS = 35;
+ int STAR = 36;
+ int DIV = 37;
+ int MOD = 38;
+ int TILDE = 39;
+ int LITERAL_TRUE = 40;
+ int LITERAL_FALSE = 41;
+ int LITERAL_typedef = 42;
+ int LITERAL_native = 43;
+ int LITERAL_float = 44;
+ int LITERAL_double = 45;
+ int LITERAL_long = 46;
+ int LITERAL_short = 47;
+ int LITERAL_unsigned = 48;
+ int LITERAL_char = 49;
+ int LITERAL_wchar = 50;
+ int LITERAL_boolean = 51;
+ int LITERAL_octet = 52;
+ int LITERAL_any = 53;
+ int LITERAL_Object = 54;
+ int LITERAL_struct = 55;
+ int LITERAL_union = 56;
+ int LITERAL_switch = 57;
+ int LITERAL_case = 58;
+ int LITERAL_default = 59;
+ int LITERAL_enum = 60;
+ int LITERAL_sequence = 61;
+ int LT = 62;
+ int GT = 63;
+ int LITERAL_string = 64;
+ int LITERAL_wstring = 65;
+ int LBRACK = 66;
+ int RBRACK = 67;
+ int LITERAL_exception = 68;
+ int LITERAL_oneway = 69;
+ int LITERAL_void = 70;
+ int LITERAL_out = 71;
+ int LITERAL_inout = 72;
+ int LITERAL_raises = 73;
+ int LITERAL_context = 74;
+ int LITERAL_fixed = 75;
+ int LITERAL_ValueBase = 76;
+ int LITERAL_import = 77;
+ int LITERAL_typeid = 78;
+ int LITERAL_typeprefix = 79;
+ int LITERAL_readonly = 80;
+ int LITERAL_attribute = 81;
+ int LITERAL_getraises = 82;
+ int LITERAL_setraises = 83;
+ int LITERAL_component = 84;
+ int LITERAL_provides = 85;
+ int LITERAL_uses = 86;
+ int LITERAL_multiple = 87;
+ int LITERAL_emits = 88;
+ int LITERAL_publishes = 89;
+ int LITERAL_consumes = 90;
+ int LITERAL_home = 91;
+ int LITERAL_manages = 92;
+ int LITERAL_primarykey = 93;
+ int LITERAL_finder = 94;
+ int INT = 95;
+ int OCTAL = 96;
+ int HEX = 97;
+ int STRING_LITERAL = 98;
+ int WIDE_STRING_LITERAL = 99;
+ int CHAR_LITERAL = 100;
+ int WIDE_CHAR_LITERAL = 101;
+ int FIXED = 102;
+ int FLOAT = 103;
+ int QUESTION = 104;
+ int DOT = 105;
+ int NOT = 106;
+ int WS = 107;
+ int SL_COMMENT = 108;
+ int ML_COMMENT = 109;
+ int ESC = 110;
+ int VOCAB = 111;
+ int DIGIT = 112;
+ int NONZERODIGIT = 113;
+ int OCTDIGIT = 114;
+ int HEXDIGIT = 115;
+ int ESCAPED_IDENT = 116;
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLVisitor.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,454 @@
+package org.apache.axis2.corba.idl.parser;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+import org.apache.axis2.corba.idl.types.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Eranga
+ * Date: Feb 11, 2007
+ * Time: 10:06:23 PM
+ */
+public class IDLVisitor implements ASTVisitor {
+ private static final Log log = LogFactory.getLog(IDLVisitor.class);
+ private IDL idl = null;
+ private String module = "";
+
+ public IDL getIDL() {
+ return idl;
+ }
+
+ public void visit(AST node) {
+ idl = new IDL();
+ while (node != null) {
+ switch (node.getType()) {
+
+ case IDLTokenTypes.LITERAL_interface: {
+ idl.addInterface(visitInterface(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_module: {
+ AST moduleName = node.getFirstChild();
+ IDLVisitor moduleVisitor = new IDLVisitor();
+ moduleVisitor.setModule(module + moduleName);
+ moduleVisitor.visit(moduleName.getNextSibling());
+ idl.addIDL(moduleVisitor.getIDL());
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_struct: {
+ idl.addType(visitStruct(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_valuetype: {
+ idl.addType(visitValueType(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_exception: {
+ idl.addType(visitException(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_enum: {
+ idl.addType(visitEnum(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_union: {
+ idl.addType(visitUnion(node));
+ break;
+ }
+
+ case IDLTokenTypes.LITERAL_typedef: {
+ visitAndAddTypedefs(node);
+ break;
+ }
+
+ default: {
+ log.error("Unsupported IDL token " + node);
+ }
+ }
+ node = node.getNextSibling();
+ }
+ }
+
+ private Struct visitStruct(AST node) {
+ AST structNode = node.getFirstChild();
+ String structName = structNode.toString();
+ Struct struct = new Struct();
+ struct.setModule(module);
+ struct.setName(structName);
+ AST memberTypeNode = structNode.getNextSibling();
+ while (memberTypeNode != null) {
+ Member member = new Member();
+ DataType dataType = findDataType(memberTypeNode);
+ AST memberNode = memberTypeNode.getNextSibling();
+ String memberName = memberNode.getText();
+ int dimensions = memberNode.getNumberOfChildren();
+ if (dimensions > 0) {
+ AST dimensionNode = memberNode.getFirstChild();
+ ArrayType arrayType = null;
+ ArrayType rootArrayType = null;
+ int i = 1;
+ while(dimensionNode!=null) {
+ ArrayType temp = new ArrayType();
+ temp.setElementModule(module);
+ temp.setElementName(memberName);
+ temp.setDepth(i);
+ i++;
+ if (arrayType != null) {
+ arrayType.setDataType(temp);
+ } else {
+ rootArrayType = temp;
+ }
+ arrayType = temp;
+ arrayType.setElementCount(Integer.parseInt(dimensionNode.getText()));
+ dimensionNode = dimensionNode.getNextSibling();
+ }
+ if (arrayType != null) {
+ arrayType.setDataType(dataType);
+ }
+ dataType = rootArrayType;
+ }
+
+ member.setDataType(dataType);
+ member.setName(memberName);
+ struct.addMember(member);
+ memberTypeNode = memberNode.getNextSibling();
+ }
+ return struct;
+ }
+
+ private ValueType visitValueType(AST node) {
+ AST valueNode = node.getFirstChild();
+ ValueType value = new ValueType();
+ value.setModule(module);
+ value.setName(valueNode.toString());
+ AST memberModifierNode = valueNode.getNextSibling();
+ while (memberModifierNode != null) {
+ String memberModifierName = memberModifierNode.toString();
+ if (!memberModifierName.equals("private") && !memberModifierName.equals("public")) {
+ if (IDLTokenTypes.PREPROC_DIRECTIVE==memberModifierNode.getType()) {
+ if (memberModifierName.startsWith("pragma ID ")) {
+ memberModifierName = memberModifierName.substring(10);
+ String[] pragma = memberModifierName.split(" ");
+ if (pragma.length==2 && pragma[0]!=null && pragma[1]!=null && pragma[0].equals(value.getName())) {
+ pragma[1] = pragma[1].replace('"', ' ');
+ value.setId(pragma[1].trim());
+ }
+ }
+ } else {
+ // abstract operation
+ value.addOperation(visitOperation(memberModifierNode));
+ }
+ memberModifierNode = memberModifierNode.getNextSibling();
+ continue;
+ }
+ Member memberType = new Member();
+ memberType.setModifier(memberModifierName);
+ AST memberTypeNode = memberModifierNode.getNextSibling();
+ memberType.setDataType(findDataType(memberTypeNode));
+ AST memberNode = memberTypeNode.getNextSibling();
+ memberType.setName(memberNode.toString());
+ value.addMember(memberType);
+ memberModifierNode = memberNode.getNextSibling();
+ }
+ return value;
+ }
+
+ private Interface visitInterface(AST node) {
+ Interface intf = new Interface();
+ intf.setModule(module);
+ AST interfaceNode = node.getFirstChild();
+ intf.setName(interfaceNode.toString());
+ 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:
+ log.error("Unsupported IDL token " + node2);
+ break;
+ case IDLTokenTypes.LITERAL_attribute:
+ intf.addOperation(visitGetAttribute(node2));
+ intf.addOperation(visitSetAttribute(node2));
+ break;
+ default:
+ if (node2.toString().startsWith("pragma ID ")) {
+ String pragmaId = node2.toString().substring(10);
+ String[] pragma = pragmaId.split(" ");
+ if (pragma.length==2 && pragma[0]!=null && pragma[1]!=null && pragma[0].equals(intf.getName())) {
+ pragma[1] = pragma[1].replace('"', ' ');
+ intf.setId(pragma[1].trim());
+ }
+ } else {
+ intf.addOperation(visitOperation(node2));
+ }
+ break;
+ }
+ node2 = node2.getNextSibling();
+ }
+ return intf;
+ }
+
+ private Operation visitGetAttribute(AST node) {
+ Operation operation = new Operation();
+ AST type = node.getFirstChild();
+ operation.setReturnType(findDataType(type));
+ AST name = type.getNextSibling();
+ operation.setName("_get_" + name.toString());
+ return operation;
+ }
+
+ private Operation visitSetAttribute(AST node) {
+ Operation operation = new Operation();
+ AST type = node.getFirstChild();
+ operation.setReturnType(PrimitiveDataType.getPrimitiveDataType("void"));
+ AST name = type.getNextSibling();
+ String attrName = name.toString();
+ operation.setName("_set_" + attrName);
+ Member param = new Member();
+ param.setName(attrName);
+ param.setDataType(findDataType(type));
+ operation.addParam(param);
+ return operation;
+ }
+
+ private Operation visitOperation(AST node) {
+ Operation operation = new Operation();
+ operation.setName(node.toString());
+ AST type = node.getFirstChild();
+ operation.setReturnType(findDataType(type));
+ AST mode = type.getNextSibling();
+ while(mode != null) {
+ if (IDLTokenTypes.LITERAL_raises == mode.getType()) {
+ AST idlType = mode.getFirstChild();
+ while(idlType != null) {
+ operation.addRaises((ExceptionType) findDataType(idlType));
+ idlType = idlType.getNextSibling();
+ }
+ } else {
+ Member param = new Member();
+ param.setMode(mode.toString());
+ AST idlType = mode.getFirstChild();
+ param.setDataType(findDataType(idlType));
+ AST paramName = idlType.getNextSibling();
+ param.setName(paramName.toString());
+ operation.addParam(param);
+ }
+ mode = mode.getNextSibling();
+ }
+ return operation;
+ }
+
+ private ExceptionType visitException(AST node) {
+ ExceptionType raisesType = new ExceptionType();
+ AST exNode = node.getFirstChild();
+ String exName = exNode.toString();
+ raisesType.setModule(module);
+ raisesType.setName(exName);
+ AST memberTypeNode = exNode.getNextSibling();
+ while (memberTypeNode != null) {
+ Member member = new Member();
+ member.setDataType(findDataType(memberTypeNode));
+ AST memberNode = memberTypeNode.getNextSibling();
+ member.setName(memberNode.toString());
+ raisesType.addMember(member);
+ memberTypeNode = memberNode.getNextSibling();
+ }
+ return raisesType;
+ }
+
+ private DataType findDataType(AST typeNode) {
+ return findDataType(typeNode, true);
+ }
+ private DataType findDataType(AST typeNode, boolean root) {
+ // Check for sequences
+ if (typeNode.getType()==IDLTokenTypes.LITERAL_sequence) {
+ return visitAnonymousSequence(typeNode, root);
+ }
+
+ DataType dataType = null;
+ Map compositeDataTypes = idl.getCompositeDataTypes();
+ String typeName = getTypeName(typeNode);
+ if (compositeDataTypes!=null) {
+ if (!module.equals("")) {
+ if (!typeName.startsWith(module)) {
+ dataType = (DataType) idl.getCompositeDataTypes().get(module + typeName);
+ }
+ }
+
+ if (dataType==null)
+ dataType = (DataType) idl.getCompositeDataTypes().get(typeName);
+ }
+
+ if (dataType==null)
+ dataType = PrimitiveDataType.getPrimitiveDataType(typeName);
+
+ return dataType;
+ }
+
+ public String getTypeName(AST node) {
+ String typeName = node.getText();
+ AST memberTypeNodeChild = node.getFirstChild();
+ while(memberTypeNodeChild!=null) {
+ typeName = typeName + "::" + memberTypeNodeChild.toString();
+ memberTypeNodeChild = memberTypeNodeChild.getNextSibling();
+ }
+ return typeName;
+ }
+
+ public void setModule(String module) {
+ if (module==null || module.length()<1)
+ module = "";
+ else if (!module.endsWith("::"))
+ module += "::";
+ this.module = module;
+ }
+
+ private EnumType visitEnum(AST node) {
+ AST enumNode = node.getFirstChild();
+ String enumName = enumNode.toString();
+ EnumType enumType = new EnumType();
+ enumType.setModule(module);
+ enumType.setName(enumName);
+ AST memberTypeNode = enumNode.getNextSibling();
+ while (memberTypeNode != null) {
+ enumType.addEnumMember(memberTypeNode.toString());
+ memberTypeNode = memberTypeNode.getNextSibling();
+ }
+ return enumType;
+ }
+
+ private UnionType visitUnion(AST node) {
+ UnionType unionType = new UnionType();
+ AST exNode = node.getFirstChild();
+ String exName = exNode.toString();
+ unionType.setModule(module);
+ unionType.setName(exName);
+ AST switchTypeNode = exNode.getNextSibling();
+ unionType.setDiscriminatorType(findDataType(switchTypeNode));
+ AST caseOrDefaultNode = switchTypeNode.getNextSibling();
+ while (caseOrDefaultNode != null) {
+ UnionMember unionMember = new UnionMember();
+ AST typeNode;
+ if (IDLTokenTypes.LITERAL_default == caseOrDefaultNode.getType()) {
+ unionMember.setDefault(true);
+ typeNode = caseOrDefaultNode.getFirstChild();
+ } else {
+ unionMember.setDefault(false);
+ AST caseValueNode = caseOrDefaultNode.getFirstChild();
+ unionMember.setDiscriminatorValue(caseValueNode.getText());
+ typeNode = caseValueNode.getNextSibling();
+ }
+
+
+ unionMember.setDataType(findDataType(typeNode));
+
+ AST memberNode = typeNode.getNextSibling();
+ unionMember.setName(memberNode.toString());
+ unionType.addMember(unionMember);
+ caseOrDefaultNode = caseOrDefaultNode.getNextSibling();
+ }
+ return unionType;
+ }
+
+ private void visitAndAddTypedefs(AST node) {
+ AST typedefNode = node.getFirstChild();
+
+ DataType dataType;
+ //SequenceType sequence = null;
+ //if (typedefNode.getType()==IDLTokenTypes.LITERAL_sequence) {
+ // sequence = visitAnonymousSequence(typedefNode);
+ // dataType = sequence.getDataType();
+ //} else {
+ dataType = findDataType(typedefNode);
+ //}
+ AST typedefNameNode = typedefNode.getNextSibling();
+ AST dimensionNode;
+ String typedefName = typedefNameNode.toString();
+ Typedef typedef;
+ while (typedefNameNode != null) {
+ int dimensions = typedefNameNode.getNumberOfChildren();
+ if (dimensions > 0) {
+ dimensionNode = typedefNameNode.getFirstChild();
+ ArrayType arrayType = null;
+ ArrayType rootArrayType = null;
+ int i = 1;
+ while(dimensionNode!=null) {
+ ArrayType temp = new ArrayType();
+ temp.setElementModule(module);
+ temp.setElementName(typedefName);
+ temp.setDepth(i);
+ i++;
+ if (arrayType != null) {
+ arrayType.setDataType(temp);
+ } else {
+ rootArrayType = temp;
+ }
+ arrayType = temp;
+ arrayType.setElementCount(Integer.parseInt(dimensionNode.getText()));
+ dimensionNode = dimensionNode.getNextSibling();
+ }
+ if (arrayType != null) {
+ arrayType.setDataType(dataType);
+ }
+ dataType = rootArrayType;
+ }
+ typedef = new Typedef();
+ typedef.setDataType(dataType);
+ typedef.setModule(module);
+ typedef.setName(typedefName);
+ idl.addType(typedef);
+ typedefNameNode = typedefNameNode.getNextSibling();
+ }
+ }
+
+ private SequenceType visitAnonymousSequence(AST node, boolean root) {
+ AST typeNode = node.getFirstChild();
+ SequenceType sequenceType = new SequenceType();
+ DataType dataType = findDataType(typeNode, false);
+ sequenceType.setDataType(dataType);
+ sequenceType.setElementModule(module);
+ AST elementNode = node.getNextSibling();
+ if (elementNode != null && root) {
+ String elementName = elementNode.getText();
+ SequenceType tempSeqType = sequenceType;
+ int i = 1;
+ DataType tempDataType;
+ while(true) {
+ tempSeqType.setElementName(elementName);
+ tempSeqType.setDepth(i);
+ i++;
+ tempDataType = tempSeqType.getDataType();
+ if (tempDataType instanceof SequenceType) {
+ tempSeqType = (SequenceType) tempDataType;
+ } else {
+ break;
+ }
+ }
+ }
+
+ AST countNode = typeNode.getNextSibling();
+ if (countNode!=null) {
+ sequenceType.setElementCount(Integer.parseInt(countNode.getText()));
+ //sequenceType.setBounded(true);
+ } else {
+ sequenceType.setElementCount(0);
+ //sequenceType.setBounded(false);
+ }
+ return sequenceType;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g Tue Sep 4 05:39:42 2007
@@ -0,0 +1,1400 @@
+header {
+ package org.apache.axis2.corba.idl;
+
+ import java.io.*;
+ import java.util.Vector;
+ import java.util.Hashtable;
+ }
+
+/**
+ * This is a complete parser for the IDL language as defined
+ * by the CORBA 3.0.2 specification. It will allow those who
+ * need an IDL parser to get up-and-running very quickly.
+ * Though IDL's syntax is very similar to C++, it is also
+ * much simpler, due in large part to the fact that it is
+ * a declarative-only language.
+ *
+ * Some things that are not included are: Symbol table construction
+ * (it is not necessary for parsing, btw) and preprocessing (for
+ * IDL compiler #pragma directives). You can use just about any
+ * C or C++ preprocessor, but there is an interesting semantic
+ * issue if you are going to generate code: In C, #include is
+ * a literal include, in IDL, #include is more like Java's import:
+ * It adds definitions to the scope of the parse, but included
+ * definitions are not generated.
+ *
+ * Jim Coker, jcoker@magelang.com
+ * Gary Duzan, gduzan@bbn.com
+ */
+class IDLParser extends Parser;
+options {
+ exportVocab=IDL;
+ buildAST=true;
+ k=4;
+}
+
+specification
+ : (import_dcl)* (definition)+
+ ;
+
+
+definition
+ : ( type_dcl SEMI!
+ | const_dcl SEMI!
+ | except_dcl SEMI!
+ | (("abstract" | "local")? "interface") => interf SEMI!
+ | module SEMI!
+ | (("abstract" | "custom")? "valuetype") => value SEMI!
+ | type_id_dcl SEMI!
+ | type_prefix_dcl SEMI!
+ | (("abstract" | "custom")? "eventtype") => event SEMI!
+ | component SEMI!
+ | home_dcl SEMI!
+ )
+ ;
+
+module
+ : "module"^
+ identifier
+ LCURLY! d:definition_list RCURLY!
+ ;
+
+definition_list
+ : (definition)+
+ ;
+
+interf
+ : ( "abstract" | "local" )?
+ "interface"^
+ identifier
+ // interface_name_dcl
+ ( interface_dcl
+ | // forward_dcl
+ )
+ ;
+
+interface_dcl
+ : interface_header
+ LCURLY! interface_body RCURLY!
+ ;
+
+// forward_dcl
+// : // interface_name_dcl
+// ;
+
+// interface_name_dcl
+// : ( "abstract" | "local" )?
+// "interface"^
+// identifier
+// ;
+
+interface_header
+ : // interface_name_dcl
+ ( interface_inheritance_spec )?
+ ;
+
+interface_body
+ : ( export )*
+ ;
+
+export
+ : ( type_dcl SEMI!
+ | const_dcl SEMI!
+ | except_dcl SEMI!
+ | attr_dcl SEMI!
+ | op_dcl SEMI!
+ | type_id_dcl SEMI!
+ | type_prefix_dcl SEMI!
+ | PREPROC_DIRECTIVE
+ )
+ ;
+
+
+interface_inheritance_spec
+ : COLON^ scoped_name_list
+ ;
+
+interface_name
+ : scoped_name
+ ;
+
+scoped_name_list
+ : scoped_name (COMMA! scoped_name)*
+ ;
+
+
+scoped_name
+ : ( SCOPEOP^ )? IDENT^ /* identifier */ (SCOPEOP! identifier)*
+ ;
+
+/*value
+ : ( value_dcl)
+ ;*/
+
+value
+ : ( value_dcl
+ | value_abs_dcl
+ | value_box_dcl
+ | value_custom_dcl
+ | value_forward_dcl
+ )
+ ;
+
+value_forward_dcl
+ : "valuetype"^
+ identifier
+ ;
+
+value_box_dcl
+ : "valuetype"^
+ identifier
+ type_spec
+ ;
+
+value_abs_dcl
+ : "abstract"
+ "valuetype"^
+ identifier
+ ( value_abs_full_dcl
+ | // value_abs_forward_dcl
+ )
+ ;
+
+value_abs_full_dcl
+ : value_inheritance_spec
+ LCURLY! ( export )* RCURLY!
+ ;
+
+// value_abs_forward_dcl
+// :
+// ;
+
+value_dcl
+ : "valuetype"^
+ identifier
+ value_inheritance_spec
+ LCURLY! (value_element)* RCURLY!
+ ;
+
+/*value_dcl
+ : value_header
+ LCURLY! ( value_element )* RCURLY!
+ ;
+*/
+value_custom_dcl
+ : "custom"^
+ value_dcl
+ ;
+
+/*value_header
+ : "valuetype"^
+ identifier
+ value_inheritance_spec
+ ;
+*/
+value_inheritance_spec
+/*
+ : ( COLON ( "truncatable" )?
+ value_name ( COMMA! value_name )*
+ )?
+ ( "supports" interface_name ( COMMA! interface_name )* )?
+ ;
+*/
+ : ( value_value_inheritance_spec )?
+ ( value_interface_inheritance_spec )?
+ ;
+
+value_value_inheritance_spec
+ : COLON^ ( "truncatable" )?
+ value_name ( COMMA! value_name )*
+ ;
+
+value_interface_inheritance_spec
+ : "supports"^ interface_name ( COMMA! interface_name )*
+ ;
+
+value_name
+ : scoped_name
+ ;
+
+value_element
+ : ( export
+ | state_member
+ | init_dcl
+ )
+ ;
+
+state_member
+ : ( "public" | "private" )
+ type_spec declarators SEMI!
+ ;
+
+init_dcl
+ : "factory"^ identifier
+ LPAREN! (init_param_decls)? RPAREN!
+ (raises_expr)?
+ SEMI!
+ ;
+
+init_param_decls
+ : init_param_decl ( COMMA! init_param_decl )*
+ ;
+
+init_param_decl
+ : init_param_attribute
+ param_type_spec
+ simple_declarator
+ ;
+
+init_param_attribute
+ : "in"
+ ;
+
+const_dcl
+ : "const"^ const_type identifier ASSIGN! const_exp
+ ;
+
+const_type
+ : (integer_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
+ ;
+
+
+/* EXPRESSIONS */
+
+const_exp
+ : or_expr
+ ;
+
+or_expr
+ : xor_expr
+ ( OR^ // or_op
+ xor_expr
+ )*
+ ;
+
+// or_op
+// : OR
+// ;
+
+
+xor_expr
+ : and_expr
+ ( XOR^ // xor_op
+ and_expr
+ )*
+ ;
+
+// xor_op
+// : XOR
+// ;
+
+and_expr
+ : shift_expr
+ ( AND^ // and_op
+ shift_expr
+ )*
+ ;
+
+// and_op
+// : AND
+// ;
+
+
+shift_expr
+ : add_expr
+ ( ( LSHIFT^
+ | RSHIFT^
+ ) // shift_op
+ add_expr
+ )*
+ ;
+
+// shift_op
+// : LSHIFT
+// | RSHIFT
+// ;
+
+
+add_expr
+ : mult_expr
+ ( ( PLUS^
+ | MINUS^
+ ) // add_op
+ mult_expr
+ )*
+ ;
+
+// add_op
+// : PLUS
+// | MINUS
+// ;
+
+mult_expr
+ : unary_expr
+ ( ( STAR^
+ | DIV^
+ | MOD^
+ ) // mult_op
+ unary_expr
+ )*
+ ;
+
+// mult_op
+// : STAR
+// | DIV
+// | MOD
+// ;
+
+unary_expr
+ : ( MINUS^
+ | PLUS^
+ | TILDE^
+ ) // unary_operator
+ primary_expr
+ | primary_expr
+ ;
+
+// unary_operator
+// : MINUS
+// | PLUS
+// | TILDE
+// ;
+
+// Node of type TPrimaryExp serves to avoid inf. recursion on tree parse
+primary_expr
+ : scoped_name
+ | literal
+ | LPAREN^ const_exp RPAREN
+ ;
+
+literal
+ : integer_literal
+ | string_literal
+ | wide_string_literal
+ | character_literal
+ | wide_character_literal
+ | fixed_pt_literal
+ | floating_pt_literal
+ | boolean_literal
+ ;
+
+boolean_literal
+ : "TRUE"
+ | "FALSE"
+ ;
+
+positive_int_const
+ : const_exp
+ ;
+
+
+type_dcl
+ : "typedef"^ type_declarator
+ | (struct_type) => struct_type
+ | (union_type) => union_type
+ | enum_type
+ | "native"^ simple_declarator
+ | constr_forward_decl
+ ;
+
+type_declarator
+ : type_spec declarators
+ ;
+
+type_spec
+ : simple_type_spec
+ | constr_type_spec
+ ;
+
+simple_type_spec
+ : base_type_spec
+ | template_type_spec
+ | scoped_name
+ ;
+
+base_type_spec
+ : (floating_pt_type) => floating_pt_type
+ | integer_type
+ | char_type
+ | wide_char_type
+ | boolean_type
+ | octet_type
+ | any_type
+ | object_type
+ | value_base_type
+ ;
+
+template_type_spec
+ : sequence_type
+ | string_type
+ | wide_string_type
+ | fixed_pt_type
+ ;
+
+constr_type_spec
+ : struct_type
+ | union_type
+ | enum_type
+ ;
+
+declarators
+ : declarator (COMMA! declarator)*
+ ;
+
+declarator
+ : simple_declarator
+ | complex_declarator
+ ;
+
+simple_declarator
+ : identifier
+ ;
+
+complex_declarator
+ : array_declarator
+ ;
+
+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"
+ ;
+
+object_type
+ : "Object"
+ ;
+
+struct_type
+ : "struct"^
+ identifier
+ LCURLY! member_list RCURLY!
+ ;
+
+member_list
+ : (member)+
+ ;
+
+member
+ : type_spec declarators SEMI!
+ ;
+
+union_type
+ : "union"^
+ identifier
+ "switch"! LPAREN! switch_type_spec RPAREN!
+ LCURLY! switch_body RCURLY!
+ ;
+
+switch_type_spec
+ : integer_type
+ | char_type
+ | boolean_type
+ | enum_type
+ | scoped_name
+ ;
+
+switch_body
+ : case_stmt_list
+ ;
+
+case_stmt_list
+ : (case_stmt)+
+ ;
+
+case_stmt
+ : // case_label_list
+ ( "case"^ const_exp COLON!
+ | "default"^ COLON!
+ )+
+ element_spec SEMI!
+ ;
+
+// case_label_list
+// : (case_label)+
+// ;
+
+
+// case_label
+// : "case"^ const_exp COLON!
+// | "default"^ COLON!
+// ;
+
+element_spec
+ : type_spec declarator
+ ;
+
+enum_type
+ : "enum"^ identifier LCURLY! enumerator_list RCURLY!
+ ;
+
+enumerator_list
+ : enumerator (COMMA! enumerator)*
+ ;
+
+enumerator
+ : identifier
+ ;
+
+sequence_type
+ : "sequence"^
+ LT! simple_type_spec opt_pos_int GT!
+ ;
+
+opt_pos_int
+ : (COMMA! positive_int_const)?
+ ;
+
+string_type
+ : "string"^ (LT! positive_int_const GT!)?
+ ;
+
+wide_string_type
+ : "wstring"^ (LT! positive_int_const GT!)?
+ ;
+
+array_declarator
+ : IDENT^ // identifier
+ (fixed_array_size)+
+ ;
+
+fixed_array_size
+ : LBRACK! positive_int_const RBRACK!
+ ;
+
+attr_dcl
+ : readonly_attr_spec
+ | attr_spec
+ ;
+
+except_dcl
+ : "exception"^
+ identifier
+ LCURLY! opt_member_list RCURLY!
+ ;
+
+
+opt_member_list
+ : (member)*
+ ;
+
+op_dcl
+ : (op_attribute)?
+ op_type_spec
+ IDENT^ // identifier
+ parameter_dcls
+ (raises_expr)?
+ (context_expr)?
+ ;
+
+op_attribute
+ : "oneway"
+ ;
+
+op_type_spec
+ : param_type_spec
+ | "void"
+ ;
+
+parameter_dcls
+ : LPAREN! (param_dcl_list)? RPAREN!
+ ;
+
+param_dcl_list
+ : param_dcl (COMMA! param_dcl)*
+ ;
+
+param_dcl
+ : ("in"^ | "out"^ | "inout"^) // param_attribute
+ param_type_spec simple_declarator
+ ;
+
+// param_attribute
+// : "in"
+// | "out"
+// | "inout"
+// ;
+
+raises_expr
+ : "raises"^ LPAREN! scoped_name_list RPAREN!
+ ;
+
+context_expr
+ : "context"^ LPAREN! string_literal_list RPAREN!
+ ;
+
+string_literal_list
+ : string_literal (COMMA! string_literal)*
+ ;
+
+param_type_spec
+ : base_type_spec
+ | string_type
+ | wide_string_type
+ | scoped_name
+ ;
+
+fixed_pt_type
+ : "fixed"^ LT! positive_int_const COMMA! positive_int_const GT!
+ ;
+
+fixed_pt_const_type
+ : "fixed"
+ ;
+
+value_base_type
+ : "ValueBase"
+ ;
+
+constr_forward_decl
+ : "struct"^ identifier
+ | "union"^ identifier
+ ;
+
+import_dcl
+ : "import"^ imported_scope SEMI!
+ ;
+
+imported_scope
+ : scoped_name
+ | string_literal
+ ;
+
+type_id_dcl
+ : "typeid"^
+ scoped_name
+ string_literal
+ ;
+
+type_prefix_dcl
+ : "typeprefix"^
+ scoped_name
+ string_literal
+ ;
+
+readonly_attr_spec
+ : "readonly" "attribute"^
+ param_type_spec
+ readonly_attr_declarator
+ ;
+
+readonly_attr_declarator
+ : simple_declarator
+ ( raises_expr
+ | (COMMA! simple_declarator)*
+ )
+ ;
+
+attr_spec
+ : "attribute"^ param_type_spec attr_declarator
+ ;
+
+attr_declarator
+ : simple_declarator
+ ( ("getraises" | "setraises") => attr_raises_expr
+ | (COMMA! simple_declarator)*
+ )
+ ;
+
+attr_raises_expr
+ : (get_excep_expr)?
+ (set_excep_expr)?
+ ;
+
+get_excep_expr
+ : "getraises"^ exception_list
+ ;
+
+set_excep_expr
+ : "setraises"^ exception_list
+ ;
+
+exception_list
+ : LPAREN! scoped_name (COMMA! scoped_name)* RPAREN!
+ ;
+
+// Component Stuff
+
+component
+ : "component"^
+ identifier
+ (component_dcl)?
+ ;
+
+component_dcl
+ : (component_inheritance_spec)?
+ (supported_interface_spec)?
+ LCURLY! component_body RCURLY!
+ ;
+
+supported_interface_spec
+ : "supports"^ scoped_name ( COMMA! scoped_name )*
+ ;
+
+component_inheritance_spec
+ : COLON^ scoped_name
+ ;
+
+component_body
+ : (component_export)*
+ ;
+
+component_export
+ : ( provides_dcl SEMI!
+ | uses_dcl SEMI!
+ | emits_dcl SEMI!
+ | publishes_dcl SEMI!
+ | consumes_dcl SEMI!
+ | attr_dcl SEMI!
+ )
+ ;
+
+provides_dcl
+ : "provides"^ interface_type identifier
+ ;
+
+interface_type
+ : ( scoped_name
+ | "Object"
+ )
+ ;
+
+uses_dcl
+ : "uses"^ ("multiple")? interface_type identifier
+ ;
+
+emits_dcl
+ : "emits"^ scoped_name identifier
+ ;
+
+publishes_dcl
+ : "publishes"^ scoped_name identifier
+ ;
+
+consumes_dcl
+ : "consumes"^ scoped_name identifier
+ ;
+
+home_dcl
+ : home_header home_body
+ ;
+
+home_header
+ : "home"^ identifier
+ (home_inheritance_spec)?
+ (supported_interface_spec)?
+ "manages"! scoped_name
+ (primary_key_spec)?
+ ;
+
+home_inheritance_spec
+ : COLON^ scoped_name
+ ;
+
+primary_key_spec
+ : "primarykey"^ scoped_name
+ ;
+
+home_body
+ : LCURLY! (home_export)* RCURLY!
+ ;
+
+home_export
+ : ( export
+ | factory_dcl SEMI!
+ | finder_dcl SEMI!
+ )
+ ;
+
+factory_dcl
+ : "factory"^ identifier
+ LPAREN! init_param_decls RPAREN!
+ (raises_expr)?
+ ;
+
+finder_dcl
+ : "finder"^ identifier
+ LPAREN! init_param_decls RPAREN!
+ (raises_expr)?
+ ;
+
+event
+ : ( event_abs
+ | event_custom
+ | event_dcl
+ )
+ ;
+
+event_header
+ : "eventtype"^
+ identifier
+ ;
+
+event_abs
+ : "abstract"^
+ event_header
+ (event_abs_dcl)?
+ ;
+
+event_abs_dcl
+ : value_inheritance_spec
+ LCURLY! (export)* RCURLY!
+ ;
+
+event_custom
+ : "custom"^
+ event_header
+ event_elem_dcl
+ ;
+
+event_dcl
+ : event_header
+ ( event_elem_dcl
+ | // event_forward_dcl
+ )
+ ;
+
+event_elem_dcl
+ : value_inheritance_spec
+ LCURLY! (export)* RCURLY!
+ ;
+
+// event_forward_dcl
+// :
+// ;
+
+/* literals */
+integer_literal
+ : INT
+ | OCTAL
+ | HEX
+ ;
+
+string_literal
+ : (STRING_LITERAL)+
+ ;
+
+wide_string_literal
+ : (WIDE_STRING_LITERAL)+
+ ;
+
+character_literal
+ : CHAR_LITERAL
+ ;
+
+wide_character_literal
+ : WIDE_CHAR_LITERAL
+ ;
+
+fixed_pt_literal
+ : FIXED
+ ;
+
+floating_pt_literal
+ : f:FLOAT
+ ;
+
+identifier
+ : IDENT
+ ;
+
+/* IDL LEXICAL RULES */
+class IDLLexer extends Lexer;
+options {
+ exportVocab=IDL;
+ charVocabulary='\u0000'..'\uFFFE';
+ k=4;
+}
+
+SEMI
+options {
+ paraphrase = ";";
+}
+ : ';'
+ ;
+
+QUESTION
+options {
+ paraphrase = "?";
+}
+ : '?'
+ ;
+
+LPAREN
+options {
+ paraphrase = "(";
+}
+ : '('
+ ;
+
+RPAREN
+options {
+ paraphrase = ")";
+}
+ : ')'
+ ;
+
+LBRACK
+options {
+ paraphrase = "[";
+}
+ : '['
+ ;
+
+RBRACK
+options {
+ paraphrase = "]";
+}
+ : ']'
+ ;
+
+LCURLY
+options {
+ paraphrase = "{";
+}
+ : '{'
+ ;
+
+RCURLY
+options {
+ paraphrase = "}";
+}
+ : '}'
+ ;
+
+OR
+options {
+ paraphrase = "|";
+}
+ : '|'
+ ;
+
+XOR
+options {
+ paraphrase = "^";
+}
+ : '^'
+ ;
+
+AND
+options {
+ paraphrase = "&";
+}
+ : '&'
+ ;
+
+COLON
+options {
+ paraphrase = ":";
+}
+ : ':'
+ ;
+
+COMMA
+options {
+ paraphrase = ",";
+}
+ : ','
+ ;
+
+DOT
+options {
+ paraphrase = ".";
+}
+ : '.'
+ ;
+
+ASSIGN
+options {
+ paraphrase = "=";
+}
+ : '='
+ ;
+
+NOT
+options {
+ paraphrase = "!";
+}
+ : '!'
+ ;
+
+LT
+options {
+ paraphrase = "<";
+}
+ : '<'
+ ;
+
+LSHIFT
+options {
+ paraphrase = "<<";
+}
+ : "<<"
+ ;
+
+GT
+options {
+ paraphrase = ">";
+}
+ : '>'
+ ;
+
+RSHIFT
+options {
+ paraphrase = ">>";
+}
+ : ">>"
+ ;
+
+DIV
+options {
+ paraphrase = "/";
+}
+ : '/'
+ ;
+
+PLUS
+options {
+ paraphrase = "+";
+}
+ : '+'
+ ;
+
+MINUS
+options {
+ paraphrase = "-";
+}
+ : '-'
+ ;
+
+TILDE
+options {
+ paraphrase = "~";
+}
+ : '~'
+ ;
+
+STAR
+options {
+ paraphrase = "*";
+}
+ : '*'
+ ;
+
+MOD
+options {
+ paraphrase = "%";
+}
+ : '%'
+ ;
+
+
+SCOPEOP
+options {
+ paraphrase = "::";
+}
+ : "::"
+ ;
+
+WS
+options {
+ paraphrase = "white space";
+}
+ : (' '
+ | '\t'
+ | '\n' { newline(); }
+ | '\r')
+ { $setType(Token.SKIP); }
+ ;
+
+
+PREPROC_DIRECTIVE
+options {
+ paraphrase = "a preprocessor directive";
+}
+
+ :
+ '#'!
+ (~'\n')* '\n'!
+ ;
+
+
+SL_COMMENT
+options {
+ paraphrase = "a comment";
+}
+
+ :
+ "//"!
+ (~'\n')* '\n'
+ { $setType(Token.SKIP); newline(); }
+ ;
+
+ML_COMMENT
+options {
+ paraphrase = "a comment";
+}
+ :
+ "/*"!
+ (
+ '\n' { newline(); }
+ | ('*')+
+ ( '\n' { newline(); }
+ | ~('*' | '/' | '\n')
+ )
+ | ~('*' | '\n')
+ )*
+ "*/"!
+ { $setType(Token.SKIP); }
+ ;
+
+CHAR_LITERAL
+options {
+ paraphrase = "a character literal";
+}
+ :
+ '\''!
+ ( ESC | ~'\'' )
+ '\''!
+ ;
+
+WIDE_CHAR_LITERAL
+options {
+ paraphrase = "a wide character literal";
+}
+ : 'L'! CHAR_LITERAL
+ ;
+
+STRING_LITERAL
+options {
+ paraphrase = "a string literal";
+}
+ :
+ '"'!
+ (ESC|~'"')*
+ '"'!
+ ;
+
+
+WIDE_STRING_LITERAL
+options {
+ paraphrase = "a wide string literal";
+}
+ :
+ 'L'! STRING_LITERAL
+ ;
+
+protected
+ESC
+options {
+ paraphrase = "an escape sequence";
+}
+ : '\\'!
+ ( 'n' {$setText("\n");}
+ | 't' {$setText("\t");}
+ | 'v' {$setText("\013");}
+ | 'b' {$setText("\b");}
+ | 'r' {$setText("\r");}
+ | 'f' {$setText("\r");}
+ | 'a' {$setText("\007");}
+ | '\\' {$setText("\\");}
+ | '?' {$setText("?");}
+ | '\'' {$setText("'");}
+ | '"' {$setText("\"");}
+ | OCTDIGIT
+ (options {greedy=true;}:OCTDIGIT
+ (options {greedy=true;}:OCTDIGIT)?
+ )?
+ {char realc = (char) Integer.valueOf($getText, 8).intValue(); $setText(realc);}
+ | 'x'! HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT)?
+ {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}
+ | 'u'!
+ HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT)?
+ )?
+ )?
+ {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}
+ )
+ ;
+
+protected
+VOCAB
+options {
+ paraphrase = "an escaped character value";
+}
+ : '\3'..'\377'
+ ;
+
+protected
+DIGIT
+options {
+ paraphrase = "a digit";
+}
+ : '0'..'9'
+ ;
+
+protected
+NONZERODIGIT
+options {
+ paraphrase = "a non-zero digit";
+}
+ : '1'..'9'
+ ;
+
+protected
+OCTDIGIT
+options {
+ paraphrase = "an octal digit";
+}
+ : '0'..'7'
+ ;
+
+protected
+HEXDIGIT
+options {
+ paraphrase = "a hexadecimal digit";
+}
+ : ('0'..'9' | 'a'..'f' | 'A'..'F')
+ ;
+
+HEX
+options {
+ paraphrase = "a hexadecimal value value";
+}
+
+ : ("0x" | "0X") (HEXDIGIT)+
+ ;
+
+INT
+options {
+ paraphrase = "an integer value";
+}
+ : NONZERODIGIT (DIGIT)* // base-10
+ ( '.' (DIGIT)*
+ ( (('e' | 'E') ('+' | '-')? (DIGIT)+) {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ | {$setType(FLOAT);}
+ )
+ | ('e' | 'E') ('+' | '-')? (DIGIT)+ {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ )?
+ ;
+
+OCTAL
+options {
+ paraphrase = "an octal value";
+}
+ : '0'
+ ( (DIGIT)+
+ | FLOAT {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ | {$setType(INT);}
+ )
+ ;
+
+
+FLOAT
+options {
+ paraphrase = "a floating point value";
+}
+
+ : '.' (DIGIT)+
+ ( ('e' | 'E') ('+' | '-')? (DIGIT)+
+ | ('d' | 'D')! {$setType(FIXED);}
+ )?
+ ;
+
+IDENT
+options {
+ paraphrase = "an identifer";
+ testLiterals = true;
+}
+
+ : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
+ ;
+
+ESCAPED_IDENT
+options {
+ paraphrase = "an escaped identifer";
+ testLiterals = false; // redundant, but explicit is good.
+}
+ // NOTE: Adding a ! to the '_' doesn't seem to work,
+ // so we adjust _begin manually.
+
+ : '_' ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
+ {_begin++;$setType(IDENT);}
+ ;
+
+
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/AbstractCollectionType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/AbstractCollectionType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/AbstractCollectionType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/AbstractCollectionType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+public abstract class AbstractCollectionType extends CompositeDataType {
+ protected int elementCount;
+ protected DataType dataType;
+ protected String elementModule;
+ protected String elementName;
+ protected int depth;
+
+ public void setElementCount(int elementCount) {
+ this.elementCount = elementCount;
+ }
+
+ public int getElementCount() {
+ return elementCount;
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public boolean isArray() {
+ return (this instanceof ArrayType);
+ }
+
+ public boolean isSequence() {
+ return (this instanceof SequenceType);
+ }
+
+ public String getElementModule() {
+ return elementModule;
+ }
+
+ public void setElementModule(String elementModule) {
+ this.elementModule = elementModule;
+ }
+
+ public String getElementName() {
+ return elementName;
+ }
+
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ public int getDepth() {
+ return depth;
+ }
+
+ public void setDepth(int depth) {
+ this.depth = depth;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ArrayType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ArrayType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ArrayType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ArrayType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+public class ArrayType extends AbstractCollectionType {
+ protected TypeCode generateTypeCode() {
+ return ORB.init().create_array_tc(elementCount, dataType.getTypeCode());
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/CompositeDataType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/CompositeDataType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/CompositeDataType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/CompositeDataType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public abstract class CompositeDataType extends DataType {
+ public static final String IDL_REPO_STRING = "IDL:";
+ public static final String IDL_VERSION = ":1.0";
+
+ protected String id;
+ protected String name;
+ protected String module;
+ protected List members = new ArrayList();
+
+ public String getId() {
+ if (id==null)
+ id = IDL_REPO_STRING + module.replaceAll("::", "/") + name + IDL_VERSION;
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void addMember(Member member) {
+ members.add(member);
+ }
+
+ public Member[] getMembers() {
+ Member[] membersArray = new Member[members.size()];
+ for (int i = 0; i < members.size(); i++) {
+ membersArray[i] = (Member) members.get(i);
+ }
+ return membersArray;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/DataType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/DataType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/DataType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/DataType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+
+public abstract class DataType {
+ protected TypeCode typeCode;
+
+ public TypeCode getTypeCode() {
+ if (typeCode==null)
+ typeCode = generateTypeCode();
+ return typeCode;
+ }
+
+ protected abstract TypeCode generateTypeCode();
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/EnumType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/EnumType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/EnumType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/EnumType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class EnumType extends CompositeDataType {
+ private List enumMembers = new ArrayList();
+
+ protected TypeCode generateTypeCode() {
+ String[] arrMembers = new String[enumMembers.size()];
+ for (int i = 0; i < enumMembers.size(); i++)
+ arrMembers[i] = (String) enumMembers.get(i);
+
+ return ORB.init ().create_enum_tc (getId(), getName(), arrMembers);
+ }
+
+ public List getEnumMembers() {
+ return enumMembers;
+ }
+
+ public void setEnumMembers(List enumMembers) {
+ this.enumMembers = enumMembers;
+ }
+
+ public void addEnumMember(String s) {
+ enumMembers.add(s);
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ExceptionType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ExceptionType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ExceptionType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ExceptionType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+public class ExceptionType extends Struct {
+ protected TypeCode generateTypeCode(){
+ return ORB.init().create_exception_tc(getId(), getName(), prepairStructMembers());
+ }
+
+// public Class getJavaType() {
+// return ExceptionValue.class;
+// }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/IDL.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/IDL.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/IDL.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/IDL.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.apache.axis2.corba.idl.types.CompositeDataType;
+import org.apache.axis2.corba.idl.types.Interface;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public class IDL {
+ private Map compositeDataTypes;
+ private Map interfaces;
+
+ public Map getCompositeDataTypes() {
+ return compositeDataTypes;
+ }
+
+ public void setCompositeDataTypes(java.util.Map compositeDataTypes) {
+ this.compositeDataTypes = compositeDataTypes;
+ }
+
+ public void addType(CompositeDataType dataType) {
+ if (compositeDataTypes == null)
+ compositeDataTypes = new TreeMap();
+ compositeDataTypes.put(dataType.getModule() + dataType.getName(), dataType);
+ }
+
+ public java.util.Map getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(java.util.Map interfaces) {
+ this.interfaces = interfaces;
+ if (compositeDataTypes == null)
+ compositeDataTypes = new TreeMap();
+ this.compositeDataTypes.putAll(interfaces);
+ }
+
+ public void addInterface(Interface intf) {
+ if (interfaces == null)
+ interfaces = new TreeMap();
+ interfaces.put(intf.getModule() + intf.getName(), intf);
+ if (compositeDataTypes == null)
+ compositeDataTypes = new TreeMap();
+ compositeDataTypes.put(intf.getModule() + intf.getName(), intf);
+ }
+
+ public void addIDL (IDL childIdl) {
+ Map temp = childIdl.getInterfaces();
+ if (temp!=null) {
+ if (interfaces==null)
+ interfaces = new TreeMap();
+ interfaces.putAll(temp);
+ }
+ temp = childIdl.getCompositeDataTypes();
+ if (temp!=null) {
+ if (compositeDataTypes==null)
+ compositeDataTypes = new TreeMap();
+ compositeDataTypes.putAll(temp);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Interface.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Interface.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Interface.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Interface.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+
+import java.util.TreeMap;
+import java.util.Iterator;
+
+public class Interface extends CompositeDataType {
+ private java.util.Map operations;
+
+ protected TypeCode generateTypeCode(){
+ return org.omg.CORBA.ORB.init ().create_interface_tc (getId(), getName());
+ }
+
+ public java.util.Map getOperationsMap() {
+ return operations;
+ }
+
+ public Operation[] getOperations() {
+ Operation[] operationsArr = new Operation[operations.size()];
+ Iterator iter = operations.values().iterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ operationsArr[i] = (Operation) iter.next();
+ i++;
+ }
+ return operationsArr;
+ }
+
+ public void addOperation(Operation operation) {
+ if (operations == null)
+ operations = new TreeMap();
+ operations.put(operation.getName(), operation);
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Member.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Member.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Member.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Member.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+public class Member {
+ protected DataType dataType;
+ protected String name;
+ protected String mode;
+ protected String modifier;
+
+ public static String MODE_IN = "in";
+ public static String MODE_INOUT = "inout";
+ public static String MODE_OUT = "out";
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ public String getModifier() {
+ return modifier;
+ }
+
+ public void setModifier(String modifier) {
+ this.modifier = modifier;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Operation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Operation.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Operation.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Operation.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class Operation {
+ private String name;
+ private List params = new ArrayList();
+ private DataType returnType;
+ private List raises = new ArrayList();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getParams() {
+ return params;
+ }
+
+ public void setParams(List params) {
+ this.params = params;
+ }
+
+ public void addParam(Member param) {
+ params.add(param);
+ }
+
+ public DataType getReturnType() {
+ return returnType;
+ }
+
+ public void setReturnType(DataType returnType) {
+ this.returnType = returnType;
+ }
+
+ public List getRaises() {
+ return raises;
+ }
+
+ public boolean hasRaises() {
+ return raises != null && (raises.size() > 0);
+ }
+
+ public void setRaises(List raises) {
+ this.raises = raises;
+ }
+
+ public void addRaises(ExceptionType exceptionType) {
+ raises.add(exceptionType);
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/PrimitiveDataType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class PrimitiveDataType extends DataType {
+ private static final Log log = LogFactory.getLog(PrimitiveDataType.class);
+
+ private static Map PRIMITIVE_TYPES = new HashMap();
+ static {
+ ORB orb = ORB.init();
+ PRIMITIVE_TYPES.put("long",orb.get_primitive_tc(TCKind.tk_long));
+ PRIMITIVE_TYPES.put("ulong",orb.get_primitive_tc(TCKind.tk_ulong));
+ PRIMITIVE_TYPES.put("longlong",orb.get_primitive_tc(TCKind.tk_longlong));
+ PRIMITIVE_TYPES.put("ulonglong",orb.get_primitive_tc(TCKind.tk_ulonglong));
+ PRIMITIVE_TYPES.put("short",orb.get_primitive_tc(TCKind.tk_short));
+ PRIMITIVE_TYPES.put("ushort",orb.get_primitive_tc(TCKind.tk_ushort));
+ PRIMITIVE_TYPES.put("float",orb.get_primitive_tc(TCKind.tk_float));
+ PRIMITIVE_TYPES.put("double",orb.get_primitive_tc(TCKind.tk_double));
+ PRIMITIVE_TYPES.put("char",orb.get_primitive_tc(TCKind.tk_char));
+ PRIMITIVE_TYPES.put("wchar",orb.get_primitive_tc(TCKind.tk_wchar));
+ PRIMITIVE_TYPES.put("boolean",orb.get_primitive_tc(TCKind.tk_boolean));
+ PRIMITIVE_TYPES.put("octet",orb.get_primitive_tc(TCKind.tk_octet));
+ PRIMITIVE_TYPES.put("string",orb.get_primitive_tc(TCKind.tk_string));
+ PRIMITIVE_TYPES.put("wstring",orb.get_primitive_tc(TCKind.tk_wstring));
+ PRIMITIVE_TYPES.put("any",orb.get_primitive_tc(TCKind.tk_any));
+ PRIMITIVE_TYPES.put("longdouble",orb.get_primitive_tc(TCKind.tk_longdouble));
+ PRIMITIVE_TYPES.put("void",orb.get_primitive_tc(TCKind.tk_void));
+ //PRIMITIVE_TYPES.put("dateTime",orb.get_primitive_tc(TCKind.tk_dateTime));
+ //PRIMITIVE_TYPES.put("date",orb.get_primitive_tc(TCKind.tk_date));
+ //PRIMITIVE_TYPES.put("time",orb.get_primitive_tc(TCKind.tk_time));
+ //PRIMITIVE_TYPES.put("positiveInteger",orb.get_primitive_tc(TCKind.tk_positiveInteger));
+ //PRIMITIVE_TYPES.put("nonPositiveInteger",orb.get_primitive_tc(TCKind.tk_nonPositiveInteger));
+ //PRIMITIVE_TYPES.put("negativeInteger",orb.get_primitive_tc(TCKind.tk_negativeInteger));
+ //PRIMITIVE_TYPES.put("nonNegativeInteger",orb.get_primitive_tc(TCKind.tk_nonNegativeInteger));
+ }
+
+ public static TypeCode getTypeCode(String typeName) {
+ return (TypeCode) PRIMITIVE_TYPES.get(typeName);
+ }
+
+ public static boolean isPrimitive(TypeCode typeCode) {
+ return typeCode != null && PRIMITIVE_TYPES.values().contains(typeCode);
+ }
+
+ public static PrimitiveDataType getPrimitiveDataType(String typeName) {
+ return new PrimitiveDataType(getTypeCode(typeName));
+ }
+
+ public PrimitiveDataType(TypeCode typeCode){
+ this.typeCode = typeCode;
+ }
+
+ protected TypeCode generateTypeCode() {
+ return typeCode;
+ }
+
+ public String getTypeName() {
+ String ret = null;
+ switch(typeCode.kind().value()) {
+ case TCKind._tk_long : ret = "int"; break;
+ case TCKind._tk_ulong : ret = "int"; break;
+ case TCKind._tk_longlong : ret = "long"; break;
+ case TCKind._tk_ulonglong : ret = "long"; break;
+ case TCKind._tk_short : ret = "short"; break;
+ case TCKind._tk_ushort : ret = "short"; break;
+ case TCKind._tk_float : ret = "float"; break;
+ case TCKind._tk_double : ret = "double"; break;
+ case TCKind._tk_char : ret = "char"; break;
+ case TCKind._tk_wchar : ret = "char"; break;
+ case TCKind._tk_boolean : ret = "boolean"; break;
+ case TCKind._tk_octet : ret = "byte"; break;
+ case TCKind._tk_string : ret = "java.lang.String"; break;
+ case TCKind._tk_wstring : ret = "java.lang.String"; break;
+ case TCKind._tk_void : ret = "void"; break;
+ default:
+ log.error("Invalid primitive data type");
+ break;
+ }
+ return ret;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/SequenceType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/SequenceType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/SequenceType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/SequenceType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+public class SequenceType extends AbstractCollectionType {
+ protected TypeCode generateTypeCode() {
+ return ORB.init().create_sequence_tc(elementCount, dataType.getTypeCode());
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Struct.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Struct.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Struct.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Struct.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+public class Struct extends CompositeDataType {
+
+ protected TypeCode generateTypeCode(){
+ return ORB.init().create_struct_tc(getId(), getName(), prepairStructMembers());
+ }
+
+ protected StructMember[] prepairStructMembers() {
+ StructMember[] structMembers = new StructMember[members.size()];
+
+ for (int i = 0; i < members.size(); i++) {
+ Member member = (Member) members.get(i);
+ TypeCode typeCode = member.getDataType().getTypeCode();
+ structMembers[i] = new org.omg.CORBA.StructMember(member.getName(), typeCode, null);
+ }
+ return structMembers;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Typedef.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Typedef.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Typedef.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/Typedef.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+
+public class Typedef extends CompositeDataType {
+ private DataType dataType;
+
+ protected TypeCode generateTypeCode() {
+ return ORB.init ().create_alias_tc (getId(), getName(), dataType.getTypeCode());
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionMember.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionMember.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionMember.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionMember.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+public class UnionMember extends Member {
+ private boolean isDefault;
+ private String discriminatorValue;
+
+ public boolean isDefault() {
+ return isDefault;
+ }
+
+ public void setDefault(boolean aDefault) {
+ isDefault = aDefault;
+ }
+
+ public String getDiscriminatorValue() {
+ return discriminatorValue;
+ }
+
+ public void setDiscriminatorValue(String discriminatorValue) {
+ this.discriminatorValue = discriminatorValue;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/UnionType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.apache.axis2.corba.receivers.CorbaUtil;
+
+public class UnionType extends CompositeDataType {
+ private DataType discriminatorType;
+
+ protected TypeCode generateTypeCode() {
+ ORB orb = ORB.init();
+ TypeCode disTypeCode = discriminatorType.getTypeCode();
+ org.omg.CORBA.UnionMember[] unmembers = new org.omg.CORBA.UnionMember [members.size()];
+
+ Any memberAny;
+ UnionMember unionMember;
+ for (int i = 0; i < members.size(); i++) {
+ unionMember = (UnionMember) members.get(i);
+ memberAny = orb.create_any();
+ if (unionMember.isDefault()) {
+ memberAny.insert_octet((byte) 0); // default member label
+ } else {
+ CorbaUtil.insertValue(memberAny, discriminatorType, CorbaUtil.parseValue(discriminatorType, unionMember.getDiscriminatorValue()));
+ }
+ unmembers[i] = new org.omg.CORBA.UnionMember (
+ unionMember.getName(),
+ memberAny,
+ unionMember.getDataType().getTypeCode(),
+ null);
+ }
+ return orb.create_union_tc (getId(), name, disTypeCode, unmembers);
+ }
+
+ public DataType getDiscriminatorType() {
+ return discriminatorType;
+ }
+
+ public void setDiscriminatorType(DataType discriminatorType) {
+ this.discriminatorType = discriminatorType;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ValueType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ValueType.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ValueType.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/types/ValueType.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.corba.idl.types;
+
+import org.omg.CORBA.*;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+import java.util.HashMap;
+
+public class ValueType extends CompositeDataType {
+ private java.util.Map operations;
+
+ protected org.omg.CORBA.TypeCode generateTypeCode(){
+ ORB orb = ORB.init();
+ ValueMember[] valueMembers = new ValueMember[members.size()];
+ String id = getId();
+ for (int i = 0; i < members.size(); i++) {
+ Member member = (Member) members.get(i);
+ TypeCode typeCode = member.getDataType().getTypeCode();
+ TCKind kind = typeCode.kind();
+ switch(kind.value()) {
+ case TCKind._tk_value :
+ String memberTypeId = "";
+ try {
+ memberTypeId = typeCode.id();
+ } catch (BadKind badKind) {
+ badKind.printStackTrace();
+ }
+ valueMembers[i] = new org.omg.CORBA.ValueMember(member.getName(), memberTypeId, id, "", typeCode,
+ null,org.omg.CORBA.PRIVATE_MEMBER.value);
+ break;
+ default:
+ valueMembers[i] = new org.omg.CORBA.ValueMember(member.getName(), "", id, "", typeCode,
+ null,org.omg.CORBA.PRIVATE_MEMBER.value);
+ break;
+ }
+ }
+ return orb.create_value_tc (id, getName(), (short)0, null, valueMembers);
+ }
+
+// public Class getJavaType() {
+// return ObjectByValue.class;
+// }
+
+ public java.util.Map getOperations() {
+ return operations;
+ }
+
+ public void setOperations(java.util.Map operations) {
+ this.operations = operations;
+ }
+
+ public void addOperation(Operation operation) {
+ if (operations == null)
+ operations = new HashMap();
+ operations.put(operation.getName(), operation);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org