/** * @see parser.IDLParserVisitor#visit(ASTsequence_type, Object) * @param data the buildinfo in use for the current scope * @return the type container for the IDLSequence type */ public Object visit(ASTsequence_type node, Object data) { CheckParameterForBuildInfo(data, node); BuildInfo containerInfo = (BuildInfo) data; SimpleNode elemTypeNode = (SimpleNode)node.jjtGetChild(0); if (containerInfo.GetContainterType() != null) { // inform the type-manager of structs/unions in creation, because // recursion using seuqneces is the only allowed recursion for structs/unions m_typeManager.PublishTypeForSequenceRecursion(containerInfo.GetContainerSymbol(), containerInfo.GetContainterType()); } Debug.WriteLine("determine element type of IDLSequence"); TypeContainer elemType = (TypeContainer)elemTypeNode.jjtAccept(this, data); // disallow further recursive use of union/struct (before next seq recursion) m_typeManager.UnpublishTypeForSequenceRecursion(); if (elemType == null) { throw new InvalidIdlException( String.Format("sequence element type not defined for {0}", node.GetIdentification())); } elemType = ReplaceByCustomMappedIfNeeded(elemType); // use here the fusioned type as element type; potential unboxing of element type // should be done by users of TypeContainer (if needed)! Debug.WriteLine("seq type determined: " + elemType.GetCompactClsType()); // create CLS array type with the help of GetType(), otherwise not possible Type arrayType; // because not fully defined types are possible, use module and not assembly to get type from Module declModule = elemType.GetCompactClsType().Module; arrayType = declModule.GetType(elemType.GetCompactClsType().FullName + "[]"); // not nice, better solution ? Debug.WriteLine("created array type: " + arrayType); // determin if sequence is bounded or unbounded long bound = 0; if (node.jjtGetNumChildren() > 1) { // bounded sequnece bound = (long) node.jjtGetChild(1).jjtAccept(this, data); } // determine the needed attributes: IdlSequence is required by the sequence itself; // combine with the attribute from the element type // possible are: IdlSequence (for sequence of sequence), ObjectIdlType, // WideChar, StringValue // invariant: boxed value attribute is not among them, because elem type // is in the compact form AttributeExtCollection elemAttributes = elemType.GetCompactTypeAttrInstances(); long seqAttrOrderNr = IdlSequenceAttribute.DetermineSequenceAttributeOrderNr(elemAttributes); IdlSequenceAttribute seqAttr = new IdlSequenceAttribute(seqAttrOrderNr, bound); AttributeExtCollection sequenceAttributes = new AttributeExtCollection(elemAttributes); sequenceAttributes = sequenceAttributes.MergeAttribute(seqAttr); TypeContainer result = new TypeContainer(arrayType, sequenceAttributes ); return result; }
public object read_boxed(BoxedValueAttribute attr, Type boxedType, AttributeExtCollection boxedTypeAttrs) { if (boxedTypeAttrs == null) { boxedTypeAttrs = AttributeExtCollection.EmptyCollection; } boxedTypeAttrs = boxedTypeAttrs.MergeAttribute(attr); return Unmarshal(boxedType, boxedTypeAttrs, m_cdrIn); }
private TypeContainer GetTypeContainerForMultiDimArray(TypeContainer elemType, int[] dimensions) { string clsArrayRep = "["; for (int i = 1; i < dimensions.Length; i++) { clsArrayRep = clsArrayRep + ","; } clsArrayRep = clsArrayRep + "]"; // create CLS array type with the help of GetType(), otherwise not possible Type arrayType; // because not fully defined types are possible, use module and not assembly to get type from Module declModule = elemType.GetCompactClsType().Module; arrayType = declModule.GetType(elemType.GetCompactClsType().FullName + clsArrayRep); // not nice, better solution ? Debug.WriteLine("created array type: " + arrayType); // determine the needed attributes: IdlArray is required by the array itself (+optional dimension attrs); // combine with the attribute from the element type // possible are: IdlArray (for array of array), IdlSequence (for array of sequence), ObjectIdlType, // WideChar, StringValue // invariant: boxed value attribute is not among them, because elem type // is in the compact form AttributeExtCollection elemAttributes = elemType.GetCompactTypeAttrInstances(); long arrayAttrOrderNr = IdlArrayAttribute.DetermineArrayAttributeOrderNr(elemAttributes); IdlArrayAttribute arrayAttr = new IdlArrayAttribute(arrayAttrOrderNr, dimensions[0]); // at least one dimension available, because of grammar AttributeExtCollection arrayAttributes = new AttributeExtCollection(elemAttributes); arrayAttributes = arrayAttributes.MergeAttribute(arrayAttr); for (int i = 1; i < dimensions.Length; i++) { IdlArrayDimensionAttribute dimAttr = new IdlArrayDimensionAttribute(arrayAttrOrderNr, i, dimensions[i]); arrayAttributes = arrayAttributes.MergeAttribute(dimAttr); } return new TypeContainer(arrayType, arrayAttributes); }